Difference between revisions of "Ns http"

From AOLserver Wiki
Jump to navigation Jump to search
m (formatting tweaks)
Line 1: Line 1:
Man page: http://aolserver.com/docs/tcl/ns_http.html
+
<manpage>ns_http</manpage>
 
 
See also: [[Ns_httpopen]]
 
 
 
----
 
  
 
'''NAME'''
 
'''NAME'''
Line 18: Line 14:
  
 
: The legal ''option''s (which may be abbreviated) are:
 
: The legal ''option''s (which may be abbreviated) are:
* '''ns_http cancel''' ''id''
+
:* '''ns_http cancel''' ''id''
* '''ns_http cleanup'''
+
:* '''ns_http cleanup'''
* '''ns_http queue''' ''method url ?body? ?headers?''
+
:* '''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.
 
: ''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?''
+
:* '''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.
 
: ''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.
Line 56: Line 52:
 
'''SEE ALSO'''
 
'''SEE ALSO'''
  
----
+
: [[ns_httpopen]]
  
[[Category Documentation]] - [[Category Core Tcl API]]
+
[[Category:Core Tcl API]]

Revision as of 04:12, 2 November 2005

<manpage>ns_http</manpage>

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

ns_httpopen