Goto: 4C Home | 4C Docs | 4C External Libraries Home | FCCom Home | FCCom Function List HttpRequest()

HttpRequest()

Purpose:
FCCom::HttpRequest() sends an http request to a server and gets the response from the server.
Usage:
ret = FCCom::HttpRequest(<connident>,<reqtype>,<resource> [, <optname>, <optval>]...);
Arguments:

integer <connident> - A connection id returned by an earlier call to FCCom::Alloc().

alpha <reqtype> - The request type. Must be a valid HTTP request type such as "GET", "POST", "PUT", etc.

alpha <resource> - The full path on the server to the resource including any queryargs.

alpha <optname> - An option needed by this request.

alpha <optval> - The value to use for the preceding <optname>.
Returns:
0 - Request completed OK. Caller needs to check "StatusCode".
1 - Request completed, but reply content was truncated in the receiving 4C var. Posssibly other warning messages in the future. So application should call sys.get_extfno[pt("FCCom","LastError") and sys.get_extfno[pt("FCCom","LastMessage")
-1 - There was an error. Caller should check "LastError".
Where Used:
FCCom::HttpRequest() can be called anytime there is a valid <connident>.
Example:
Example
Description:
FCCom::HttpRequest() sends an http request to a server and gets the response from the server. The <optname>, <optval> pairs that can be passed to this function and are only valid for this single request are: It is valid to specify both <reply-content> and <reply-content-fn>.

If the connection is not currently open, FCCom::HttpRequest() will first connect to the server before sending the request.

If the server responds, the FCCom library will read all response headers and process the ones it needs to including saving cookies that will be sent with the next request that uses the same <connident>.
Bugs/Features/Comments:
See Also:
FCCom Function List


Back to Top