Updated and Reviewed December 2010
(Windows only; see Comments, below, for ATE interface) This routine handles various kinds of HTTP requests.
xcall HTTP, opcode, status, flags, url, request, response
Parameters
opcode (Num) [in]
1 (XHTTPOP_REQ) = general HTTP request
status (Signed number) [out]
0 = ok (for simple functions)
>0 = response code returned from HTTP server (generally means that operation succeeded in communicating with the server; whether that represents an unqualified success will depend on the application and the body of the response.)
<0 = Operational errors (see ASHINC:HTTP.DEF HTTPERR_xxx)
flags (Num) [in]
sum of options flags. These flags are listed in ASHINC:HTTP.DEF.
|
Symbol |
Value |
Description |
|
XHTTPF_SSL |
&h0001 |
Use SSL |
|
XHTTPF_REQPOST |
&h0002 |
Tells upload routine to use POST format |
|
XHTTPF_REQUPLOAD |
&h0004 |
Upload files (variation of POST) |
|
XHTTPF_REQHEAD |
&h0008 |
Makes the request a HEAD request |
|
XHTTPF_REQXML |
&h0010 |
Makes the request a POST using text/xml content |
|
XHTTPF_REQGET |
&h0020 |
Simple GET (text of HTML page) |
|
XHTTPF_REQPUT |
&h0040 |
Simple PUT |
|
XHTTPF_DOWNLOAD |
&h0080 |
Download a file |
|
XHTTPF_FILEREQ |
&h0100 |
Request arg is a filespec (or list of) not a string |
|
XHTTPF_FILERESP |
&h0200 |
Response arg is a filespec not a buffer |
|
XHTTPF_DEBUG |
&h0400 |
Outputs copy of generated request to DEBUG.REQ |
|
XHTTPF_HDRBODY |
&h0800 |
Parse file into headers (added individually) and body |
|
XHTTPF_PARMBODY |
&h1000 |
Like HDRBODY but use AddParam instead of AddHeader |
|
XHTTPF_SETFROMURL |
&h2000 |
Extract path and form info from URL |
|
XHTTPF_FORCEXFR |
&h4000 |
File parms are server-relative; transfer to PC |
url (String) [in]
Fully qualified URL, with optional path and/or {:port}. For example:
"http://www.microsabio.net/dist/51dev/temphold/junk.zip"
"https://www.paypal.com"
"http://someserver.com/some/path:10080"
request (String) [in]
Contains content of the request, for operations that require it, such as uploading files, POST, etc. Depending on XHTTPF_FILEREQ flag, may be a string buffer or a filespec (preferably native). For the XHTTPF_REQUPLOAD option, can be a list of filespecs with semi-colon delimiter. Note that some options only work with file mode, while some may only work with string mode.
response (String) [in/out]
Body of the response. Depending on XHTTPF_FILERESP, it is the filespec (preferably native) of a file, or a string buffer to return the response in. For errors that return STATUS<0, it may contain debugging text about the error rather than the actual response.
Comments
To access this function from a server (connected to by an ATE client), you can use the SOSLIB wrapper routine ATHTTP.SBX. It uses essentially the same calling format (limited, however, to the file mode operations), but handles the communication and data transfers between the server and the ATE client. See the ATHTTP.BP source code in [907,33] for further details, and the HTTP1.BP sample program in [908,25] for an example of calling it.
History
2009 September, build 1159: added to A-Shell