Basically, this allows you to send HTTP Requests without having to type the IP and Port at the end of your request.
Add this to the bottom of your HTTPWrapper control:
Code:
Public Function GetProxyWrapper(URL As String, Optional Referer As String = "") As String
Dim TempRef As String
Dim HostX As String
Dim Tempfile As String
Dim FileX As String
If Referer <> "" Then
TempRef = "Referer: " & Referer & vbCrLf
Else
TempRef = ""
End If
Call WaitForWinSockClose
If LCase$(Left$(URL, 7)) = "http://" Then
Tempfile = Mid$(URL, 8)
Else
Tempfile = URL
End If
FileX = URL
If Winsock1.State <> 0 Then
Winsock1.Close
Call WaitForWinSockClose
End If
Winsock1.RemoteHost = HostP
Winsock1.RemotePort = PortP
Winsock1.LocalPort = 0
If Not StopIT And Winsock1.State <> 7 Then
Winsock1.Connect
End If
Call WaitForWinSockConnect
If Not StopIT Then
Winsock1.SendData GETPage(FileX, HostP, TempRef)
End If
Call WaitForWinSockClose
LastPage = URL
If LCase$(Left$(URL, 7)) <> "http://" Then
LastPage = "http://" & LastPage
End If
If DontParseHttp Then
GetProxyWrapper = strKomplett
Else
GetProxyWrapper = HTTParse(strKomplett)
End If
End Function
Public Function PostProxyWrapper(URL As String, Datastring As String) As String
Dim TempRef As String
Dim HostX As String
Dim Tempfile As String
Dim FileX As String
If Referer <> "" Then
TempRef = "Referer: " & Referer & vbCrLf
Else
TempRef = ""
End If
If LCase$(Left$(URL, 7)) = "http://" Then
Tempfile = Mid$(URL, 8)
Else
Tempfile = URL
End If
FileX = URL
If Winsock1.State <> 0 Then
Winsock1.Close
Call WaitForWinSockClose
End If
Winsock1.RemoteHost = HostP
Winsock1.RemotePort = PortP
Winsock1.LocalPort = 0
If Not StopIT And Winsock1.State <> 7 Then
Winsock1.Connect
End If
Call WaitForWinSockConnect
If Not StopIT Then
Winsock1.SendData FormPOST(FileX, HostP, Datastring, TempRef)
End If
Call WaitForWinSockClose
LastPage = URL
If LCase$(Left$(URL, 7)) <> "http://" Then
LastPage = "http://" & LastPage
End If
If DontParseHttp Then
PostWrapper = strKomplett
Else
PostWrapper = HTTParse(strKomplett)
End If
End Function
Public Function SetProxy(IP As String, Port As String) As String
Dim HostStore As String, PortStore As String
HostStore = Winsock1.LocalIP
PortStore = Winsock1.LocalPort
HostP = IP
PortP = Port
End Function
Public Function RemoveProxy()
Winsock1.RemoteHost = HostStore
Winsock1.RemotePort = PortStore
End Function The commands are used as follows:
Set the IP and port for Winsock
Code:
strHTML = Wrapper.SetProxy(IP, Port)
Sets the remote address and port back to its normal settings
Code:
strHTML = Wrapper.RemoveProxy()
Go to the URL entered using the proxy settings
Code:
strHTML = Wrapper.GetProxyWrapper(URL, referrer)
Post at the URL using the proxy settings
Code:
strHTML = Wrapper.PostProxyWrapper(URL, dataToPost, referrer)
I wrote this because it was annoying for me to sit there and type in the IP and Port every time I wanted to send an HTTP request.