471,618 Members | 1,315 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

HttpWebResponse how does it end

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 images,
i.e., does it only makes one "GET / HTTP/1.1\r\n\r\n"?

Because I'm doing some projects on a webclient (to measure some
statistic times) and the total bytes get byte HttpWebResponse are lower
than the total objects I get via socket way.

In other words, does HttpWebResponse only gets the specified html page
without any objects? When there is no Content-Length property, how does
it know when the page ends?

All the replies I got, were unclear about this matter. Sorry for the
repost.

Thanks for any reply,
Nuno Magalhaes.

Nov 30 '05 #1
2 2297
I'm not following you. It sounds as though you are asking several different
questions, but mixing them together. One is about the HttpWebResponse class,
and the other is about the HTTP protocol.

A single HttpWebResponse is going to encapsulate one HTTP response. If an
HTML document sent in a Response has images in it, for example, the initial
Response will not contain any images, but image tags in HTML for the page
returned. Each image tag identifies the URL for that image, and a separate
Request must be sent to the server for each additional resource.

As to your description regarding the "total bytes" from an HttpWebResponse
(I think) versus "socket way" doesn't contain enough information about what
"socket way" refers to to, what "total bytes" refers to, or what "total
objects" refers to, to make a guess as to what exactly you're talking about,
or what is going on.

As to your question about how a .Net client application (not an
HttpWebResponse) knows when "the page" ends, you might want to read up on
the HTTP protocol. The following is a nice, fairly succinct explanation of
the HTTP protocol:

http://www.jmarshall.com/easy/http/

It is important to distinguish between the client application that is
processing the Response and the HttpWebResponse object. The HttpWebResponse
object does not create the Response at all. It is created on a .Net client
when an HTTP Response is received from the server. It is simply a class that
encapsulates all of the HTTP Response message received by the client.

It also might be noted that an HttpWebResponse class instance is not an HTTP
Response message, but a class that encapsulates the message. The message
itself is simply a text stream that is sent from the server.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
If you push something hard enough,
it will fall over.
- Fudd's First Law of Opposition

"Nuno Magalhaes" <nu************@hotmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
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 images,
i.e., does it only makes one "GET / HTTP/1.1\r\n\r\n"?

Because I'm doing some projects on a webclient (to measure some
statistic times) and the total bytes get byte HttpWebResponse are lower
than the total objects I get via socket way.

In other words, does HttpWebResponse only gets the specified html page
without any objects? When there is no Content-Length property, how does
it know when the page ends?

All the replies I got, were unclear about this matter. Sorry for the
repost.

Thanks for any reply,
Nuno Magalhaes.

Nov 30 '05 #2
Nuno,

When you view a page in a web browser, the browser parses the HTML that
comes from the server, and fetches separate requests for the items in the
page which need to be loaded.

HttpWebRequest will not do this. If you want to do this, you will need
to parse the content, resolve all relative urls, and then fetch the items in
the page.

As for not knowing when there is no content length property, I believe
that the connection is closed, which tells the client that there is no more.

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

"Nuno Magalhaes" <nu************@hotmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
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 images,
i.e., does it only makes one "GET / HTTP/1.1\r\n\r\n"?

Because I'm doing some projects on a webclient (to measure some
statistic times) and the total bytes get byte HttpWebResponse are lower
than the total objects I get via socket way.

In other words, does HttpWebResponse only gets the specified html page
without any objects? When there is no Content-Length property, how does
it know when the page ends?

All the replies I got, were unclear about this matter. Sorry for the
repost.

Thanks for any reply,
Nuno Magalhaes.

Nov 30 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Jason Manfield | last post: by
4 posts views Thread by Nuno Magalhaes | last post: by
3 posts views Thread by Nuno Magalhaes | last post: by
1 post views Thread by Brent | last post: by
6 posts views Thread by Leon_Amirreza | last post: by
1 post views Thread by Morgan Cheng | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
1 post views Thread by ZEDKYRIE | last post: by

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.