ReceiveHTTPMemory()
Syntax
*Buffer = ReceiveHTTPMemory(URL$ [, Flags [, UserAgent$]])Description
Download a file to a new memory buffer from the given URL$.
Parameters
URL$ The URL to download from. Flags (optional) It can be a combination of the following values: #PB_HTTP_Asynchronous: starts the download asynchronously. To get the memory buffer address use FinishHTTP(). #PB_HTTP_NoRedirect : don't follow automatic redirections.UserAgent$ (optional) Change the user agent for the HTTP request. Default user agent is set to "Mozilla/5.0 Gecko/41.0 Firefox/41.0" for maximum compatibility.
Return value
Returns the new memory buffer address if the download was successful, zero otherwise. MemorySize() can be used to get the size of the downloaded item. The memory buffer needs to be freed with FreeMemory() once finished using it. If #PB_HTTP_Asynchronous was specified, it returns the 'HttpConnection' value needed for HTTPProgress(), AbortHTTP() and FinishHTTP(). When using #PB_HTTP_Asynchronous, FinishHTTP() needs to be called when the download is finished (successfully or not).
Remarks
On Linux, 'libcurl' needs to be installed to have this command working (most of Linux distributions comes with it already installed).
Example
*Buffer = ReceiveHTTPMemory("http://www.purebasic.com/index.php") If *Buffer Size = MemorySize(*Buffer) Debug "Content: " + PeekS(*Buffer, Size, #PB_UTF8|#PB_ByteLength) FreeMemory(*Buffer) Else Debug "Failed" EndIf
See Also
URLEncoder()
Supported OS
All