Home > comp > gb.net.curl > httpclient 
 en fr de es it nl pl pt pt_BR mk sq hu cs tr ar fa id vi ko ja ru zh zh_TW eo
Previous  Next  Edit  Rename  Undo  Search  Administration  
THIS WIKI IS DEPRECATED AND IS READ-ONLY. THE NEW WIKI IS THERE.
Documentation  
Warning! This page is not translated.  See english version 
HttpClient (gb.net.curl)
Symbols
This class inherits Curl.
Properties  Methods  Events 
Async  Blocking  ByteOrder  Debug  Downloaded  EndOfFile  EndOfLine  ErrorText  Handle  Lines  Password  Proxy  SSL  Status  Tag  Timeout  TotalDownloaded  TotalUploaded  URL  Uploaded  User    Begin  Close  Drop  Peek  ReadLine  Send    Connect  Error  Finished  Progress  Read   

This class is creatable.

Properties  Methods 
Auth  Code  CookiesFile  Encoding  Headers  Reason  UpdateCookies  UserAgent    Get  Post  PostFile  Put  Stop   

Example

' How to download a file from the internet synchronously

' Put the "Async" property set to FALSE prior to Get(), that way
' Get() will stop the program flow until all the information is
' received. In that case you should use also the "TimeOut" property to
' set a timeout. If not, it could hang forever if the server does not
' reply properly.

Public Sub GetFile()

  Dim hClient As HttpClient
  Dim sBuffer As String

  hClient = New HttpClient AS "hClient"
  hClient.URL = "http://elinks.or.cz/"
  hClient.Async = FALSE
  hClient.Timeout = 60
  hClient.Get

  Print "Begin"
  If hClient.Status < 0 Then
    Print "ERROR"
  Else
    ' Success - read the data
    If Lof(hClient) Then sBuffer = Read #hClient, Lof(hClient)
    Print sBuffer
  End If

  Print "end"

End

Example #2

This second example shows how you can download a file from the internet asynchronously.

It calls the DownloadAsync method with your URL. Then, when the download is completed, it displays the received HTML in the Finished event handler.

' How to download a file from the internet asynchronously

Public hAsyncClient As New HttpClient AS "hAsyncClient"
Private sDownloadBuffer As String

Public Sub DownloadAsync(URL As String)

  sDownloadBuffer = ""
  hAsyncClient.URL = URL
  hAsyncClient.TimeOut = 20
  hClient.Async = TRUE
  hAsyncClient.Get()

End

Public Sub hAsyncClient_Connect()

  Print "Connected to " & hAsyncClient.URL

End

Public Sub hAsyncClient_Read()

  Dim sBuffer As String

  sBuffer = Read #Last, Lof(Last)
  sDownloadBuffer &= sBuffer

End

Public Sub hAsyncClient_Error()

  Print "Error " & hAsyncClient.Status & " while downloading " & hAsyncClient.URL

End

Public Sub hAsyncClient_Finished()

  Print sDownloadBuffer

End