Return to index

web functions

local_name = download(url_string)

top

Downloads from URL url_string and stores the returned data in the file local_name. Includes console feedback.

Example:

# Example for download
println download("https://example.com")  # saved file name


string = html_escape(string)

top

Converts HTML special characters to ampersand values.

Example:

# Example for html_escape
println html_escape("<b>hi</b>")  # "&lt;b&gt;hi&lt;/b&gt;"


string = html_unescape(string)

top

Converts a string containing ampersand values to include HTML special characters.

Example:

# Example for html_unescape
println html_unescape("&lt;div&gt;")  # <div>


device_string = net_interfaces()

top

newline separated list of device names.

Example:

# Example for net_interfaces
println net_interfaces()


bool = web_cache_cleanup_interval(int)

top

Set the number of requests between cache cleanups.


bool = web_cache_enable(bool)

top

Enable or disable web caching globally.


bool = web_cache_max_age(int)

top

Set the maximum age of cached entries in seconds.


bool = web_cache_max_memory(int)

top

Set the maximum memory usage for cache in MB.


bool = web_cache_max_size(int)

top

Set the maximum number of cached entries.


bool = web_cache_purge()

top

Manually purge all cached entries.


map = web_cache_stats()

top

Return cache statistics: size, hits, misses, memory usage.


string = web_custom(method_string,loc_string[,[string]assoc_headers_strings])

top

Returns a string with content downloaded from loc_string.

Example:

# Example for web_custom
println web_custom("GET","https://example.com")  # response content


web_display()

top

Show configured request routing.


bool_okay = web_download(url_string,local_file)

top

Downloads from URL url_string and stores the returned data in the file local_file.

Example:

# Example for web_download
println web_download("https://example.com","/tmp/example")


structure = web_get(loc_string)

top

Returns a structure with content downloaded from loc_string. .result is the content string. .code is the status code.

Example:

# Example for web_get
println web_get("https://example.com").result


bool = web_gzip_enable(bool)

top

Enable or disable gzip compression for responses.


bool = web_head(loc_string)

top

Makes a HEAD request of the given loc_string. Returns true if retrieved successfully.

Example:

# Example for web_head
println web_head("https://example.com")  # true


int = web_max_clients()

top

(read-only) returns the maximum permitted client count for a web server.

Example:

# Example for web_max_clients
println web_max_clients()  # e.g., 100


result_string = web_post(loc_string,[]key_value_list)

top

Perform a HTTP POST.

Example:

# Example for web_post
println web_post("https://example.com",["key","val"])


[]any = web_raw_send(method_string,url_string,headers_map,body_string)

top

Send HTTP request with custom method, headers, and raw body. Returns [body, headers, status_code].


call_details = web_serve_decode(webcallstruct)

top

Returns a struct representing details of an inbound web request.

[#SOL]web_serve_decode() returns the following member fields:

[#SOL] .host (host:port), .method, .path, .remote (remote_ip:port) and .data (POST data).

Example:

# Example for web_serve_decode
var w={"host":"localhost:80","path":"/","data":"hi"}
println web_serve_decode(w)  # struct fields


web_serve_log(args)

top

Write arguments to the web log file, if available.

Example:

# Example for web_serve_log
web_serve_log("entry")


web_serve_log_throttle(start,freq)

top

Set the throttle controls for web server logging.

Example:

# Example for web_serve_log_throttle
web_serve_log_throttle(10,20)


string = web_serve_path(handle,action_type,request_regex,new_path)

top

Provides a traffic routing instruction to a web server.

Example:

# Example for web_serve_path
id=web_serve_start(".",8080)
web_serve_path(id,"s","/old","/new")


handle = web_serve_start(docroot,port[,vhost])

top

Returns an identifier for a new http server.

Example:

# Example for web_serve_start
println web_serve_start("/var/www",8080)


success_flag = web_serve_stop(handle)

top

Stops and discards a running http server.

Example:

# Example for web_serve_stop
id=web_serve_start(".",8080)
web_serve_stop(id)


bool = web_serve_up(handle)

top

Checks if a web server is still running.

Example:

# Example for web_serve_up
println web_serve_up(server_handle)  # true/false