AsyncResponse
Previous Top Next

Retrieves the response that was previously received from the server.
This property should only be used inside the Respone event.

Syntax: AsyncResponse As HttpWebResponse

Example:
Sub Globals
      total = 0
      URL = "http://www.basic4ppc.com/images/modules.jpg"
End Sub

Sub App_Start
      Form1.Show
      request.New1(URL)
      response.New1
      request.GetAsyncResponse
End Sub

Sub request_Response
      If request.ResponseCode = 200 Then '200 is the code of successful connections.
            response.Value = request.AsyncResponse
            total = Round(Response.ContentLength/1000)
            response.GetAsyncStream(AppPath & "\tempImage.jpg")
            timer1.Enabled = True
            btnCancel.Enabled = True
      Else
            Msgbox("Error getting response: " & request.ErrorMessage & CRLF _
            & "Response code: " & request.ResponseCode)
      End If
End Sub

Sub response_Stream
      Msgbox("Finished downloading file.")
      timer1.Enabled = False
End Sub

Sub Timer1_Tick
      label1.Text = "Download " & Round(response.DownloadedBytes / 1000) &" kb out of " & total & " kb"
End Sub

Sub btnCancel_Click
      response.CancelStream = True
      timer1.Enabled = False
End Sub