W
Winger
Hi,
I'm using a HttpWebRequest/HttpWebResponse to get plain html code off a
website. This is the code:
(...)
Dim Resp As HttpWebResponse
Try
Resp = CType(request.GetResponse(), HttpWebResponse)
Catch ex As Exception
MsgBox(ex.ToString)
Return False
End Try
Dim resp1, resp2 As Integer
resp1 = CInt(Resp.ContentLength)
Dim sr As StreamReader = New StreamReader(Resp.GetResponseStream(),
Encoding.Default)
Dim s As String = sr.ReadToEnd()
resp2 = s.Length
If resp1 <> resp2 Then
MsgBox("My HTTP response was cut!")
End If
The problem is that the last expression often and randomly evaluates to
true (Resp.ContentLength = 153850 and s.Length = 152450). Because of
that the end of the HTML code is missing. When randomly s.Length
evaluates to 153850, everything is ok and I have the full HTML code from
the server.
Does anyone have any idea on what could be causing this?
I'm using a HttpWebRequest/HttpWebResponse to get plain html code off a
website. This is the code:
(...)
Dim Resp As HttpWebResponse
Try
Resp = CType(request.GetResponse(), HttpWebResponse)
Catch ex As Exception
MsgBox(ex.ToString)
Return False
End Try
Dim resp1, resp2 As Integer
resp1 = CInt(Resp.ContentLength)
Dim sr As StreamReader = New StreamReader(Resp.GetResponseStream(),
Encoding.Default)
Dim s As String = sr.ReadToEnd()
resp2 = s.Length
If resp1 <> resp2 Then
MsgBox("My HTTP response was cut!")
End If
The problem is that the last expression often and randomly evaluates to
true (Resp.ContentLength = 153850 and s.Length = 152450). Because of
that the end of the HTML code is missing. When randomly s.Length
evaluates to 153850, everything is ok and I have the full HTML code from
the server.
Does anyone have any idea on what could be causing this?