Building HTTP Components
Do-it-yourself, with plenty of clothing, here's how to build your own asphttp components.
Using the Winsock control, the following describes how to build a simple HTTP component.
Remember to select the Mswinsck.ocx control first
The following code is compiled in VB6.
The code is as follows:
Private WithEvents Objwinsock as Mswinsocklib.winsock
Private strURL as String
Private Struri as String
Private Strserver as String
Private Nport as Long
Private Strhead as String
Private Strdata as String
Private bconnected as Boolean
Public Function HttpGet (URL As String) as String
Set Objwinsock = New Mswinsocklib.winsock
strURL = URL
parseURL
Connect
SendRequest
Objwinsock.close
Strhead = Left (strdata, InStr (strdata, VbCrLf & VbCrLf))
Strdata = Right (Strdata, Len (strdata)-InStr (Strdata, VbCrLf & VbCrLf))
HttpGet = Strdata
End Function
Private Sub parseURL ()
If LCase (Left (strURL, 7)) = "http://" Then
If InStr (8, strURL, "/") = 0 Then
Strserver = Right (strURL, Len (strURL)-7)
Struri = "/"
Else
strserver = Mid (strURL, 8, INSTR (8, strURL, "/")-8)
Struri = Right (strURL, Len (strURL)-INSTR (8, strURL, "/") + 1)
End If
If InStr (strserver, ":") <> 0 Then
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.