Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
HTTP POST with Progress MonitoringNote: Version 2.2.3 released on 27-June-2007 is required for this example. The source code for this example is available here: VB6 HTTP POST Demonstrates how to do an HTTP POST with progress monitoring. ' Dim sending As Boolean Dim WithEvents http As ChilkatHttp Private Sub Command5_Click() Set http = New ChilkatHttp http.UnlockComponent "Anything for 30-day trial" http.HeartbeatMs = 100 ' You may use this exact URL for testing. ' The full URL is a combination of the hostname passed to ' SynchronousRequest (below) and the req.Path. In this case, ' it is http://www.chilkatsoft.com/cgi-bin/BigResp.exe Dim req As New ChilkatHttpRequest req.UsePost req.Path = "/cgi-bin/BigResp.exe" req.AddParam "test", "123" ' Make one of the POST parameters large so that the HTTP request ' to be sent is large. This allows for progress monitoring to ' be seen. (If the HTTP request were too small, the send might ' be instantaneous.) Dim s As String s = "abcdefghijklmnopqrstuvwxyz" For i = 1 To 1000 s = s + "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz" Next req.AddParam "big", s sending = True ' Send the HTTP POST and get the response. Dim response As ChilkatHttpResponse Set response = http.SynchronousRequest("www.chilkatsoft.com", 80, 0, req) Text1.Text = http.LastErrorText + vbCrLf + response.BodyStr End Sub ' The AbortCheck event is called periodically according to the ' HeartbeatMs property setting. Private Sub http_AbortCheck(abort As Long) If (ProgressBar2.Value > 95) Then ProgressBar2.Value = 0 Else ProgressBar2.Value = ProgressBar2.Value + 5 End If End Sub ' This event fires just before beginning to receive the HTTP response. Private Sub http_BeginReceive() List1.AddItem "Begin Receive" sending = False End Sub ' This event fires just before beginning to send the HTTP POST. Private Sub http_BeginSend() List1.AddItem "Begin Send" sending = True End Sub ' This event fires just after the HTTP response has been received in full. ' (or after a failure in reading the response). If reading the response ' failed, success is set to 0. Otherwise it is set to 1. Private Sub http_EndReceive(ByVal success As Long) List1.AddItem "End Receive" End Sub ' This event fires just after the HTTP request has been sent. ' (or after a failure in sending the request). If sending the request ' failed, success is set to 0. Otherwise it is set to 1. Private Sub http_EndSend(ByVal success As Long) List1.AddItem "End Send" sending = False End Sub ' The PercentDone event is fired during sending and receiving. ' The pctDone argument will contain a value from 1 to 100. Private Sub http_PercentDone(ByVal pctDone As Long) If (sending) Then ProgressBar1.Value = pctDone Else ProgressBar3.Value = pctDone End If End Sub |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.