NaviServer - programmable web server


[ Main Table Of Contents | Table Of Contents | Keyword Index ]

ns_http(n) 4.99.5 naviserver "NaviServer Built-in Commands"

Name

ns_http - Simple HTTP client functionality

Table Of Contents

Synopsis

Description

This command provides a simple HTTP client mechanism.

COMMANDS

ns_http cancel id

Cancel queued http request by id (ns_set id of request).

ns_http cleanup

Cancel all pending http requests

ns_http list

Return the list of currently running or pending requests in format: id url done|running ....

ns_http queue ?-method M? ?-headers S? ?-body B? ?-timeout T?

-method use the specified HTTP method such as GET or POST or HEAD

-headers headers is the ns_set ID containing the additional headers to include in the HTTP request. -body body is the value which will be sent as the HTTP request body. -timeout Timeout for how long to wait reply back from the web server

The command ns_http queue returns the ns_set ID of the HTTP request, which might be used later for waiting for this request or canceling this request.

ns_http run ?-method M? ?-headers S? ?-body B? ?-timeout T?

Send a HTTP reuqest and wait for the result. The command ns_http run is similar to ns_http queue followed by ns_http wait.

ns_http wait ?-result var? ?-status var? ?-timeout t? ?-headers H? ?-elapsed var? id

-elapsed var is the name of a variable that should be used to store the elapsed time for the request from beginning to finish

-result var is the name of a variable that should be used to store the HTTP response body.

-status var is the name of a variable that should be used to store the HTTP response status

-timeout Default timeout is "2:0" (2s, 0usec).

-headers headers is the ns_set ID which will receive the headers from the HTTP response.

id ns_set ID of the HTTP request to wait for.

EXAMPLES

 % ns_http queue http://www.google.com
 % http0
 % ns_http wait -status status -result result http0
 % 1

See Also

ns_httpget, ns_httppost, ns_httptime, ns_ssl

Keywords

http-client