Class wwHTTP |
wwHTTP::AddPostkey |
wwIPStuff::OnHTTPBufferUpdate |
wwIPStuff::HTTPGetHeader |
wwIPStuff::HTTPGetEx |
West Wind Internet Protocols 4.68 |
wwHTTP::HTTPGetEx
|
Note: Use HTTPGet when you can!
in most cases you do not need to use this method, but rather simply use HTTPGET() which has simpler syntax. The main reason to use this function is to be able to download content directly to a file.
Syntax: |
o.HTTPGetEx(tcPage, @tcBuffer, @tnBufferSize, tcHeaders, tcFileName) |
| Return: | 0 on success, an error number on failure. |
| Parameters: |
tcPage The Web server relative link to retrieve. Typically this will be an HTML page or a script page. Example: /wonnect/default.htm @tcBuffer @tnBufferSize tcHeaders "Referer: http://myserver.com/somelink.htm" + CRLF + ; "User-Agent: Rick's great Browser V1.0" +CRLF +; "Custom: Wonk it!" tcFileName |
| Example: | oHTTP = CREATEOBJECT("wwHttp")
*** Connect to the server
oHTTP.HTTPConnect("www.west-wind.com")
*** Let's post some data TO the server
oHTTP.AddPostKey("Client","B")
oHTTP.AddPostKey("FromDate","01/01/96")
*** Initialize the variables that will be filled by HTTPGetEx
lcHTML=""
lnText=0
*** Send the POST data and retrieve HTTP result
lnResult=oHTTP.HTTPGetEx("/wconnect/wc.dll?wwDemo~ShowHours",;
@lcHTML,@lnText)
IF lnResult # 0
? lnResult, oHTTP.cErrorMsg
RETURN
ENDIF
? TRIM(lcHTML)
* ShowHTML( lcHTML )
oHTTP.HTTPClose() && Close the connection
|
| Remarks: | HTTPGetEx also supports an optional 'event method' interface. You can subclass wwIPStuff and implement a method called OnHTTPBufferUpdate() in which case this method is called whenever wwIPStuff receives a chunk of data. When the result returns you can also retrieve cHTTPHeader to see any HTTP headers that were returned from the server. Other properties to check out: nHTTPPort - If you want to use other ports than 80/443 |
See also: