Discussion:
wininet vb5
(too old to reply)
Jeff Micksch
2004-04-27 22:03:51 UTC
Permalink
I have an application that puts together data to simulate a posted form.
Until recently this code has worked. Now I am getting noise in the data
stream.

I've eliminated network, server and data stream creation issues. It seems as
if the data is created properly but is then corrupted when received by the
server.

Basically I'm sending one posted variable, but that variable may be rather
long (up to 300KB or so).

Here's the way I'm sending...

Dim scUserAgent As String
scUserAgent = "my process"

Dim hOpen As Long, hFile As Long, sBuffer As String, Ret As Long,
hRequest As Long, bRes As Long

'Create an internet connection
hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_PRECONFIG,
vbNullString, vbNullString, 0)

Dim hConnect As Long
hConnect = InternetConnect(hOpen, URL, CLng(Port), vbNullString,
vbNullString, _
INTERNET_SERVICE_HTTP, 0, 0)
hRequest = HttpOpenRequest(hConnect, "POST", , "HTTP/1.0", vbNullString,
0, _
HTTPConnectType, 0)
Dim sHeader As String
Dim bResult As Boolean

sHeader = "Content-Type: application/x-www-form-urlencoded" & vbCrLf
bResult = HttpAddRequestHeaders(hRequest, sHeader, Len(sHeader),
HTTP_ADDREQ_FLAG_REPLACE Or HTTP_ADDREQ_FLAG_ADD)

sHeader = "Connection: Keep-Alive" & vbCrLf
bResult = HttpAddRequestHeaders(hRequest, sHeader, Len(sHeader),
HTTP_ADDREQ_FLAG_REPLACE Or HTTP_ADDREQ_FLAG_ADD)
'Open the url
bRes = HttpSendRequest(hRequest, vbNullString, 0, HeaderData,
Len(HeaderData))

sBuffer = Space(10000)
'Read the first 10000 bytes of the file
InternetReadFile hRequest, sBuffer, 10000, Ret
'clean up
InternetCloseHandle hFile
InternetCloseHandle hOpen
sBuffer = Trim(sBuffer)


The noise that I'm getting is unexpected exclamation points "!", usually
followed by carriage return/line feed combination (chr(13), chr(10)).
Sometimes it is just the exclamation point with a space after it.

I don't see this noise until after about 1600 characters have been read by
the web server. But after that, the errors are not always the same space
apart. However, they will occur at the exact same spots for the same data
set.


Has anyone else seen problems like this. Anyhelp would be greatly
appreciated.

Jeff
Jeff Micksch
2004-04-29 17:08:23 UTC
Permalink
Never mind. I found the culprit. It had nothing to do with wininet or vb5.
Continue reading on narkive:
Loading...