Home > comp > gb.net.curl > httpclient 
 en fr de es it pl pt pt_BR mk sq ca hu cs tr ar fa id vi ko ja ru zh zh_TW eo
Voorgaande  Volgende  Bewerken  Hernoemen  Undo  Search  Administratie  
Waarschuwing Deze pagina is niet vertaald.  Zie Engelse versie 
HttpClient (gb.net.curl)
Deze klass erft Curl.
Eigenschappen  Metode  Evenementen 
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   

Deze klass is aan te maken.

Eigenschappen  Metode 
Auth  Code  CookiesFile  Encoding  Headers  Reason  UpdateCookies  UserAgent    Get  Post  PostFile  Put  Stop   


' 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

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

  Print "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


Public Sub hAsyncClient_Connect()

  Print "Connected to " & hAsyncClient.URL


Public Sub hAsyncClient_Read()

  Dim sBuffer As String

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


Public Sub hAsyncClient_Error()

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


Public Sub hAsyncClient_Finished()

  Print sDownloadBuffer