Hi,
I need to post data to a webpage using the winsock control.
I know how to do this with XMLhttp and wininet but here i need to do this
either with winsock or inet control.
The client machine is behind a proxy that requires authentication.
I have looked up articles on vbip.com but they arent working for pages that
are on a SSL secured server.
Does any body have code or a handy function that will accept connection type
( proxy or direct) the proxy username ,proxy password and the URL and the
port of the remore server.
I know inet contorl provides all this but i cant seem to get it to work
with the proxy that requires authentication
i tried this with inet.
'// start code
Public Function GetMyHeadURL(strURL As String, myPort As String, UserName As
String, Password As String, HTTPDomain As String) As String
Dim strTest, myHeader, myBase64, AuthenticationHead As String
Dim string2, GetPageInfo As String
Inet1.AccessType = icUseDefault
Inet1.RemotePort = myPort
Inet1.Protocol = icHTTP
myBase64 = Base64_Encode(Trim(UserName) & ":" & Trim(Password))
'headerInfo = "Authorization: Basic R2FycmV0dDpmb3p6aWU4"
AuthenticationHead = "Proxy-Connection: Keep-Alive" & vbCrLf &
"Authorization: Basic " & myBase64 & vbCrLf
'Retrieve the file as a string. This send and get data back.
Inet1.Execute strURL, "get", " ", AuthenticationHead
Do
DoEvents
Loop While Inet1.StillExecuting
string2 = ""
GetPageInfo = Inet1.GetChunk(1024, icString)
Do Until Trim(GetPageInfo) = ""
string2 = string2 & GetPageInfo
GetPageInfo = ""
GetPageInfo = Inet1.GetChunk(1024, icString)
Loop
string2 = Replace(string2, "SRC=""", "SRC=""" & HTTPDomain)
string2 = Replace(string2, "src=""", "SRC=""" & HTTPDomain)
string2 = Replace(string2, "HREF=""", "HREF=""" & HTTPDomain)
string2 = Replace(string2, "href=""", "HREF=""" & HTTPDomain)
GetMyHeadURL = string2
End Function
Private Function Base64_Encode(strSource) As String
'
Const BASE64_TABLE As String
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
'
Dim strTempLine As String
Dim j As Integer
'
For j = 1 To (Len(strSource) - Len(strSource) Mod 3) Step 3
'Breake each 3 (8-bits) bytes to 4 (6-bits) bytes
'
'1 byte
strTempLine = strTempLine + Mid(BASE64_TABLE, (Asc(Mid(strSource, j,
1)) \ 4) + 1, 1)
'2 byte
strTempLine = strTempLine + Mid(BASE64_TABLE, ((Asc(Mid(strSource,
j, 1)) Mod 4) * 16 _
+ Asc(Mid(strSource, j + 1, 1)) \ 16) + 1, 1)
'3 byte
strTempLine = strTempLine + Mid(BASE64_TABLE, ((Asc(Mid(strSource, j
+ 1, 1)) Mod 16) * 4 _
+ Asc(Mid(strSource, j + 2, 1)) \ 64) + 1, 1)
'4 byte
strTempLine = strTempLine + Mid(BASE64_TABLE, (Asc(Mid(strSource, j
+ 2, 1)) Mod 64) + 1, 1)
Next j
'
If Not (Len(strSource) Mod 3) = 0 Then
'
If (Len(strSource) Mod 3) = 2 Then
'
strTempLine = strTempLine + Mid(BASE64_TABLE,
(Asc(Mid(strSource, j, 1)) \ 4) + 1, 1)
'
strTempLine = strTempLine + Mid(BASE64_TABLE,
(Asc(Mid(strSource, j, 1)) Mod 4) * 16 _
+ Asc(Mid(strSource, j + 1, 1)) \ 16 + 1, 1)
'
strTempLine = strTempLine + Mid(BASE64_TABLE,
(Asc(Mid(strSource, j + 1, 1)) Mod 16) * 4 + 1, 1)
'
strTempLine = strTempLine & "="
'
ElseIf (Len(strSource) Mod 3) = 1 Then
'
'
strTempLine = strTempLine + Mid(BASE64_TABLE, Asc(Mid(strSource,
j, 1)) \ 4 + 1, 1)
'
strTempLine = strTempLine + Mid(BASE64_TABLE,
(Asc(Mid(strSource, j, 1)) Mod 4) * 16 + 1, 1)
'
strTempLine = strTempLine & "=="
'
End If
'
End If
'
Base64_Encode = strTempLine
'
End Function
// end code
this doesnt seem to pass authentication info properly in inet, but the same
authentication header works fine with winsock
Any help will be highly appreciated
TIA
Satya
*********************************************************
Disclaimer
This message (including any attachments) contains
confidential information intended for a specific
individual and purpose, and is protected by law.
If you are not the intended recipient, you should
delete this message and are hereby notified that
any disclosure, copying, or distribution of this
message, or the taking of any action based on it,
is strictly prohibited.
*********************************************************
Visit us at http://www.mahindrabt.com