West Wind Internet Protocols 4.68 |
wwHTTP::HTTPGetExAsync
|
Syntax: |
o.HTTPGetExAsync(tcPage,tcResultFile,tnResultSize,tcHeaders) |
| Return: | nothing |
| Parameters: |
tcPage Link on the server to load. (/Default.htm) tcResultFile tnResultSize tcHeaders tnSecondsBeforeDelete |
| Example: | CLEAR
DO WCONNECT
loIP = CREATEOBJECT("wwHTTP")
loIP.HTTPConnect("www.west-wind.com")
loIP.AddPostkey("FirstName","Rick")
loIP.AddPostkey("Company",TIME())
loIP.AddPostKey("LastName","STRAHL")
lcFile = SYS(2023) + "\AsyncTest.htm"
ERASE (lcFile)
loIP.HTTPGetExAsync("/wconnect/wc.dll?wwdemo~TestPage",;
lcFile,40000,"",10)
loIP.HTTPClose()
*** The following is a simulation of some check code
*** this could be done off a timer or some other processing
*** that took place instead of in this poll loop
lnSeconds = SECONDS()
*** Simulate checking for file
DO WHILE SECONDS() - lnSeconds < 15
lcResult = File2Var(lcFile)
? "Checking...",LEN(lcResult)
IF EMPTY(lcResult)
DOEVENTS
LOOP
ENDIF
*** We got our result - let's delete the file
*** to signal the thread we're done to kill the thread
ERASE (lcFile)
EXIT
ENDDO
*** Just display the result as HTML
SHOWHTML(lcResult)
|
| Remarks: | The result file basically controls the lifetime of the async thread as well as the response communication with the calling application. When the file can be opened ( lnHandle=FOPEN(tcFileName,0) with lnHandle being a positive value or File2Var() returning a string ) the thread is done writing the data from the HTTP request, otherwise the file is still locked and the data not complete. Once the file's been written completely the thread will wait for tnSecondsBeforeDelete seconds before erasing the file or until the file is deleted externally by your app. Once either of these events occur the thread is released. If you will display the result file or otherwise persist the data it's recommended you copy it to a new location or a string and then delete the original. If you quit Visual FoxPro while an async thread is active, VFP will crash! |
See also: