Home All Groups Group Topic Archive Search About

HttpWebResponse is truncated

Author
22 Jan 2007 9:47 PM
Dean Rettig
I am using HttpWebRequest to get an HttpWebResponse from an https://
site.

I am using cookies and certificates and everything seems to be working
properly EXCEPT...

The largest (html) document that I am trying to read is about 28788
bytes when downloaded using Firefox

but when my dotnet app tries to retrieve it, the response is only about
26580 bytes. Here is a code snippet:

HttpWebResponse response = (HttpWebResponse) request.GetResponse ( );
System.Text.Encoding enc = System.Text.Encoding.GetEncoding(1252);  //
Windows default Code Page
System.IO.StreamReader reader = new System.IO.StreamReader(
response.GetResponseStream(), enc );
string content = reader.ReadToEnd();
reader.Close();
response.Close();

I've tried different methods of StreamReader all with the same results.
Can anyone tell me where the last 2KB of my response is going and how
I can get it back?

Muchas grathias,
Dean

Author
25 Jan 2007 7:20 PM
Joerg Jooss
Thus wrote Dean,

Show quote
> I am using HttpWebRequest to get an HttpWebResponse from an https://
> site.
>
> I am using cookies and certificates and everything seems to be working
> properly EXCEPT...
>
> The largest (html) document that I am trying to read is about 28788
> bytes when downloaded using Firefox
>
> but when my dotnet app tries to retrieve it, the response is only
> about 26580 bytes. Here is a code snippet:
>
> HttpWebResponse response = (HttpWebResponse) request.GetResponse ( );
> System.Text.Encoding enc = System.Text.Encoding.GetEncoding(1252);  //
> Windows default Code Page
> System.IO.StreamReader reader = new System.IO.StreamReader(
> response.GetResponseStream(), enc );
> string content = reader.ReadToEnd();
> reader.Close();
> response.Close();
> I've tried different methods of StreamReader all with the same
> results.
> Can anyone tell me where the last 2KB of my response is going and how
> I can get it back?

Try to do a binary download of the file. You could dump the response stream
to a file and check if it has the expected length. Maybe the response contains
a byte sequence (like 0x00 ) that makes the decoder stumble.

Cheers,
--
Joerg Jooss
news-re***@joergjooss.de
Author
19 Feb 2007 1:32 PM
Dean Rettig
I've figured it out.  It had nothing to do with HttpWebRequest.

I was trying to display the results in a Textbox and wasn't aware that
it had a max string length limit of 32768 characters

thanks everyone..

On Jan 25, 2:20 pm, Joerg Jooss <news-re***@joergjooss.de> wrote:
Show quote
> Thus wrote Dean,
>
>
>
> > I am using HttpWebRequest to get an HttpWebResponse from an https://
> > site.
>
> > I am using cookies and certificates and everything seems to be working
> > properly EXCEPT...
>
> > The largest (html) document that I am trying to read is about 28788
> > bytes when downloaded using Firefox
>
> > but when my dotnet app tries to retrieve it, the response is only
> > about 26580 bytes. Here is a code snippet:
>
> > HttpWebResponse response = (HttpWebResponse) request.GetResponse ( );
> > System.Text.Encoding enc = System.Text.Encoding.GetEncoding(1252);  //
> > Windows default Code Page
> > System.IO.StreamReader reader = new System.IO.StreamReader(
> > response.GetResponseStream(), enc );
> > string content = reader.ReadToEnd();
> > reader.Close();
> > response.Close();
> > I've tried different methods of StreamReader all with the same
> > results.
> > Can anyone tell me where the last 2KB of my response is going and how
> > I can get it back?
>
> Try to do a binary download of the file. You could dump the response stream
> to a file and check if it has the expected length. Maybe the response contains
> a byte sequence (like 0x00 ) that makes the decoder stumble.
>
> Cheers,
> --
> Joerg Jooss
> news-re***@joergjooss.de

AddThis Social Bookmark Button