473,386 Members | 1,943 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

HttpWebResponse is truncated

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

Jan 23 '07 #1
4 3069
Dean Rettig <re******@gmail.comwrote:
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?
How sure are you that it's encoded in Windows-1252?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 25 '07 #2
Jon,

I thought of that.

I've tried all of the popular encodings and plain raw binary and get
the same thing. I think I'll try them all again just to make sure.

I'm beginning to think that there is some latency/timeout that is
causing the response to timeout and return before it has received all
of the data.

Dean

On Jan 25, 4:00 pm, Jon Skeet [C# MVP] <s...@pobox.comwrote:
Dean Rettig <retti...@gmail.comwrote:
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?How sure are you that it's encoded in Windows-1252?

--
Jon Skeet - <s...@pobox.com>http://www.pobox.com/~skeet Blog:http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 29 '07 #3
On Jan 29, 4:37 pm, "Dean Rettig" <retti...@gmail.comwrote:
I thought of that.

I've tried all of the popular encodings and plain raw binary and get
the same thing. I think I'll try them all again just to make sure.

I'm beginning to think that there is some latency/timeout that is
causing the response to timeout and return before it has received all
of the data.
That sounds unlikely. Have you looked at what's coming in over the
network using something like Ethereal?

Jon

Jan 29 '07 #4
On Jan 29, 11:43 am, "Jon Skeet [C# MVP]" <s...@pobox.comwrote:
On Jan 29, 4:37 pm, "Dean Rettig" <retti...@gmail.comwrote:
I thought of that.
I've tried all of the popular encodings and plain raw binary and get
the same thing. I think I'll try them all again just to make sure.
I'm beginning to think that there is some latency/timeout that is
causing the response to timeout and return before it has received all
of the data.

That sounds unlikely. Have you looked at what's coming in over the
network using something like Ethereal?

Jon
Thanks Jon - I found the problem and it was unrelated to
HttpWebRequest/Response.

I was writing (some debuging info and) the output in a Textbox with
the max string length set to 32768 which was clipping it.
I increased the textbox max length to 1000000 and now I can see all of
it.

thanks for your ideas.

Dean

Feb 19 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Denny Rue | last post by:
I’ve created VB code to download files from a web site through the use of HTTPWebRequest, HTTPWebResponse and BinaryReader. The HTTPWebRequest has a TimeOut property to limit how long it waits...
0
by: hlabbott | last post by:
Hi I'm having a problem displaying attachments correctly. I have messages with attachments stored on Exchange2000 and want to be able to click a hyperlink in my project like in OWA and see an...
1
by: Ravi | last post by:
Hi , i am trying to pass the same session Id to all the webrequest, but sometimes the response.cookies returns zero and sometimes one. is this to do something with cookies expire. In this sample...
13
by: Jason Manfield | last post by:
For some URLs (e.g.http://v3.espacenet.com/origdoc?DB=EPODOC&IDX=WO2005028634&F=0&QPN=WO2005028634), the content length for the HttpWebResponse I get with request.GetResponse in empty. The...
1
by: Jason Manfield | last post by:
Why does HttpWebResponse.CharacterSet always return ISO-8859-1? I am accessing a Chinese Web site (http://cn.yahoo.com) -- View Source in IE shows the character set to be "gb2312", but the...
3
by: Nuno Magalhaes | last post by:
Hello, In a simple thread I have a code like the one below: public void ProtectionRun() { while(true) { //Sleep thread for one minute //Thread.Sleep(60000); HttpWebRequest
2
by: Noggin The Nog | last post by:
Hi all, I've been trying to get HttpWebResponse to work, but whenever I try I get "The operation has timed-out". I'm simply trying to send an HTTP request querystring to a remote website and read...
2
by: Nuno Magalhaes | last post by:
In pages that there is no content length, how does HttpWebResponse knows where the page ends? And what kind of objects/methods does it retrieve? Does it only retrieve the initial page without any...
9
by: ThePants | last post by:
Hi, given the following code, I've been successful in grabbing pages for parsing, but for a certain page template (containing a particular piece of code) the stream always ends right after that...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.