473,403 Members | 2,183 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,403 software developers and data experts.

HttpWebResponse

I'm using HttpWebRequest and HttpWebResponse to pull data from a web page.
Sometimes I don't get the complete content, but sometimes, even when this
happens, I get no exceptions either.

I thought I'd use the ContentLength property of the WebResponse to determine
if I've received all the data, but that always returns -1 (at least for the
pages I'm downloading).

What I'd like to do is re-queue the request if I don't get the complete
response, but I can't figure out how to be sure.

I do occasionally get WebExceptions for things like timeouts and other
problems, and I'm able to handle those fine. So I'm not sure why some of
these pages (maybe 1 in 30 or so) are coming back only partially. The site's
servers are heavily loaded which is why I don't always get the complete
response. If I load it up in a browser, I sometimes only get the partial
page as well, so browsers have the same problem, so I don't think it's my
code for reading the stream.

Thanks.

Fredo
Jul 15 '06 #1
2 2203
Fredo,

Unfortunately, you can't do anything about this. It is the server that
is having the problem, not you. Unless you know of some identifier in the
content of the page which indicates it is complete (which you can search
for), there is nothing that I can think of you could check for.

The reason that the ContentLength property returns -1 sometimes is
because the response does not send the Content-length header. Usually, for
dynamically-generated pages, it doesn't return this, since it can not know
the length of the content before it is generated.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Fredo" <fr***@hotmail.comwrote in message
news:Wv******************************@giganews.com ...
I'm using HttpWebRequest and HttpWebResponse to pull data from a web page.
Sometimes I don't get the complete content, but sometimes, even when this
happens, I get no exceptions either.

I thought I'd use the ContentLength property of the WebResponse to
determine if I've received all the data, but that always returns -1 (at
least for the pages I'm downloading).

What I'd like to do is re-queue the request if I don't get the complete
response, but I can't figure out how to be sure.

I do occasionally get WebExceptions for things like timeouts and other
problems, and I'm able to handle those fine. So I'm not sure why some of
these pages (maybe 1 in 30 or so) are coming back only partially. The
site's servers are heavily loaded which is why I don't always get the
complete response. If I load it up in a browser, I sometimes only get the
partial page as well, so browsers have the same problem, so I don't think
it's my code for reading the stream.

Thanks.

Fredo

Jul 15 '06 #2
Nicholas,

Thanks for the information. Disappointing, but I guess I'll just have to
figure out some way of determining the integrity of the response.

Fredo

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.comwrote in
message news:OT**************@TK2MSFTNGP04.phx.gbl...
Fredo,

Unfortunately, you can't do anything about this. It is the server that
is having the problem, not you. Unless you know of some identifier in the
content of the page which indicates it is complete (which you can search
for), there is nothing that I can think of you could check for.

The reason that the ContentLength property returns -1 sometimes is
because the response does not send the Content-length header. Usually,
for dynamically-generated pages, it doesn't return this, since it can not
know the length of the content before it is generated.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Fredo" <fr***@hotmail.comwrote in message
news:Wv******************************@giganews.com ...
>I'm using HttpWebRequest and HttpWebResponse to pull data from a web
page. Sometimes I don't get the complete content, but sometimes, even
when this happens, I get no exceptions either.

I thought I'd use the ContentLength property of the WebResponse to
determine if I've received all the data, but that always returns -1 (at
least for the pages I'm downloading).

What I'd like to do is re-queue the request if I don't get the complete
response, but I can't figure out how to be sure.

I do occasionally get WebExceptions for things like timeouts and other
problems, and I'm able to handle those fine. So I'm not sure why some of
these pages (maybe 1 in 30 or so) are coming back only partially. The
site's servers are heavily loaded which is why I don't always get the
complete response. If I load it up in a browser, I sometimes only get the
partial page as well, so browsers have the same problem, so I don't think
it's my code for reading the stream.

Thanks.

Fredo


Jul 16 '06 #3

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...
1
by: Brent | last post by:
I thought I was doing a simple thing, here -- asking a server for a text document, getting the first 150 lines, and then returning the lines. But I keep getting timeout errors: "Exception...
15
by: Snedker | last post by:
I'm using (HttpWebRequest and HttpWebResponse to check for updates. But how do I determine the size of the file before download? What I have in mind is a status text like "You have downloaded...
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.