Ns http

From AOLserver Wiki
Revision as of 19:07, 12 May 2005 by WikiSysop (talk | contribs) (imported from WiKit id 577)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Man page: http://aolserver.com/docs/tcl/ns_http.html


NAME

ns_http - Simple HTTP client functionality

SYNOPSIS

ns_http option ?arg arg ...?

DESCRIPTION

This command provides a simple HTTP client mechanism.
The legal options (which may be abbreviated) are:
  • ns_http cancel id
  • ns_http cleanup
  • ns_http queue method url ?body? ?headers?
body is the value which will be sent as the HTTP request body. headers is the ns_set ID containing the additional headers to include in the HTTP request.
  • ns_http wait id resultsVar ?timeout? ?headers? ?-servicetime svcTime?
resultsVar is the name of a variable that should be used to store the HTTP response body. Default timeout is "2:0" (2s, 0usec). headers is the ns_set ID which will receive the headers from the HTTP response.

EXAMPLES

Valid HTTP GET:

 % set id ns_http queue GET http://aolserver.com/
 http0
 % set status ns_http wait $id results
 1
 % string range $results 0 60
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN

Timed out HTTP GET:

 % set id ns_http queue GET http://aolserver.com:12345/
 http0
 % set status ns_http wait $id results 0
 0
 % set results
 timeout

Bogus HTTP GET:

 % catch {ns_http queue GET http://nonexistant.domain/} err
 1
 % set err
 could not connect to : http://nonexistant.domain/

SEE ALSO


Category Documentation - Category Core Tcl API