Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / February 2007

Tip: Looking for answers? Try searching our database.

HttpWebResponse is truncated

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dean Rettig - 22 Jan 2007 21:47 GMT
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
Laurent Bugnion [MVP] - 25 Jan 2007 08:29 GMT
Hi,

> I am using HttpWebRequest to get an HttpWebResponse from an https://
> site.
[quoted text clipped - 23 lines]
> Muchas grathias,
> Dean

It's possible that the code sent from the server to the client is
different depending on the client's user agent string. Rather than
checking the response size, check if the code is complete (you don't say
if it is), i.e. if a valid document is sent back.

HTH,
Laurent
Signature

Laurent Bugnion [MVP ASP.NET]
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch

Joerg Jooss - 25 Jan 2007 19:20 GMT
Thus wrote Dean,

> I am using HttpWebRequest to get an HttpWebResponse from an https://
> site.
[quoted text clipped - 20 lines]
> 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,
Signature

Joerg Jooss
news-reply@joergjooss.d

Dean Rettig - 19 Feb 2007 13:32 GMT
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..

> Thus wrote Dean,
>
[quoted text clipped - 31 lines]
> Joerg Jooss
> news-re...@joergjooss.de

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.