Hej. Jag har läst om en eventuell förklaring till felet "error 122".Lång url med HttpOpenRequest?
Vi har ett problem med att när url överstiger 2075 tecken så returnerar HttpOpenRequest-metoden ett fel, error 122.
Känner någon till detta problem och vet en lösning?
mvh
marie
exempel:
Private Function OpenURL(Url As String) As String
Dim hInternetSession As Long
Dim hInternetConnect As Long
Dim hHttpOpenRequest As Long
Dim iRetVal As Integer
Dim lBufferLen As Long
Dim sStatus As String
Dim bDoLoop As Boolean
Dim sReadBuffer As String * 2048
Dim lNumberOfBytesRead As Long
Dim sBuffer2 As String
hInternetSession = InternetOpen("http sample", 0, vbNullString, vbNullString, 0)
lBufferLen = Len(sBuffer)
If CBool(hInternetSession) Then
hInternetConnect = InternetConnect(hInternetSession, Url, 80, _
vbNullString, vbNullString, 3, 0, 0)
If hInternetConnect > 0 Then
hHttpOpenRequest = HttpOpenRequest(hInternetConnect, "POST", "", "HTTP/1.0", vbNullString, 0, _
&H80000000, 0) 'här uppstår felet!
If CBool(hHttpOpenRequest) Then
iRetVal = HttpSendRequest(hHttpOpenRequest, vbNullString, 0, 0, 0)
If iRetVal Then
bDoLoop = True
While bDoLoop
sReadBuffer = vbNullString
bDoLoop = InternetReadFile(hHttpOpenRequest, sReadBuffer, Len(sReadBuffer), lNumberOfBytesRead)
sBuffer2 = sBuffer2 & Left$(sReadBuffer, lNumberOfBytesRead)
If Not CBool(lNumberOfBytesRead) Then bDoLoop = False
Wend
txtHTML = sBuffer2
Else
' HttpSendRequest failed
sStatus = "HttpSendRequest call failed; Error code: " & Err.LastDllError & "."
txtHTML = ""
End If
Else
' HttpOpenRequest failed
sStatus = "HttpOpenRequest call failed; Error code: " & Err.LastDllError & "."
txtHTML = ""
End If
Else
' InternetConnect failed
sStatus = "InternetConnect call failed; Error code: " & Err.LastDllError & "."
txtHTML = ""
End If
Else
' hInternetSession handle not allocated
sStatus = "InternetOpen call failed: Error code: " & Err.LastDllError & "."
txtHTML = ""
End If
OpenURL = txtHTML
End FunctionSv: Lång url med HttpOpenRequest?
http://msdn.microsoft.com/library/periodic/period96/protocol.htm
Hoppas att det kan vara till någon hjälp!
/Mikromjuk