473,386 Members | 2,129 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.

Getting the HTTP Content-Length Parameter

I'm doing a "low level" project that consists on monitoring certain QoS
parameters such as: Time to resolve dns, time to connect, time to
receive data, time to receive all web page, time to close connection,
between others...
Since that I cannot use any higher level procedures such as WebClient,
HTTPWebRequest and Response.

The problem is that I'm not getting the "Content-Length" parameter in
the HTTP response header. Do you know if passing to server "GET /
HTTP/1.1\n\n" is enough to receive the "Content-Length" parameter,
because I'm not receiving it.

Any hints on this matter,
Any expert on HTTP headers and servers?

Thanks for any reply,
Nuno Magalhaes.

P.S.: One person told me here that using "HEAD / HTTP/1.1\r\n" would
give me the content-length of the html page. Is that true?

Nov 27 '05 #1
1 3423
Nuno Magalhaes wrote:
I'm doing a "low level" project that consists on monitoring certain
QoS parameters such as: Time to resolve dns, time to connect, time to
receive data, time to receive all web page, time to close connection,
between others...
Since that I cannot use any higher level procedures such as WebClient,
HTTPWebRequest and Response.

The problem is that I'm not getting the "Content-Length" parameter in
the HTTP response header. Do you know if passing to server "GET /
HTTP/1.1\n\n" is enough to receive the "Content-Length" parameter,
because I'm not receiving it.

Any hints on this matter,
Any expert on HTTP headers and servers?
Nuno, please realize that reimplementing a complete HTTP stack isn't
trivial at all. You can post your questions in 5 minutes intervals here
and still the answers won't become more encouraging...

The first thing to understand is that HTTP is based on a spec. If you
need to deal with, read it:
http://www.w3.org/Protocols/rfc2616/rfc2616.html

To give you a headstart, a Content-Length header is not a required
reponse header, *if* the response contains a Connection: close header
(which terminates the conversation) or uses Transfer-Encoding: chunked
(which means the response is split up into several fragments, usually
done for large reponse bodies such all file donwloads).
P.S.: One person told me here that using "HEAD / HTTP/1.1\r\n" would
give me the content-length of the html page. Is that true?


No, HEAD will only give you the same response as GET without the
response body. As far as headers are concerned, the spec says:
"The metainformation contained in the HTTP headers in response to a
HEAD request SHOULD be identical to the information sent in response to
a GET request."

But a quick test shows that this only a SHOULD, and *should not* be
relied upon (pun somewhat intended).

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 27 '05 #2

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

Similar topics

4
by: projecktzero | last post by:
Well, I've managed to get an image into a postgre database, but now I'm having trouble getting it out. #! /usr/bin/env python from pyPgSQL import PgSQL def main(): connectdb =...
5
by: Brandons of mass destruction | last post by:
Ok, I work for a small newspaper thats looking to translate our content to the web. XML sounds like a good way to do this, but i'm a little confused. Is it possible to have <b> and <i> tags in...
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
8
by: bryan | last post by:
Is there any way I can get the application path (the one returned by Request.ApplicationPath) in the Application_Start method in Global.asax? Request is not valid there. On a related note, is there...
2
by: Praveen | last post by:
Hi All, I have made a webservice in C# and it works fine in my machine. I ran into a crazy problem when I wanted to deploy it in windows 2003 server. I have run "aspnet_regiis.exe -i" to make...
0
by: ptraj | last post by:
Dear ppls, I'm doing a small project to extract all messages from outlook by Visual Basic 6.0 and write them into a file(in MBOX format). While accessing messages i able to get headers, body,...
8
by: Amit | last post by:
I have a master page and a content page but the stylesheet isnt getting applied like how it looks in visual studio design view. The master page is defined like this: <%@ Master Language="VB"...
6
by: DRS.Usenet | last post by:
When I run alert("page contents:" + content.document.documentElement.innerHTML); I am able to pull the content. I see something like this page contents:<head><title>A Title</title>...
1
by: FLX | last post by:
Hello, I'm trying to scrape daily titles from http://www.doopes.com/?cat=35444&lang=1&num=5&mode=0&from=2007-09-04&to=2007-09-04&exc=&inc=&opt=0 But i'm getting lost using preg_match. Can someone...
1
by: kigoobe | last post by:
Hi friends, I'm having three queries that works perfectly ... SELECT ib.id as id, ib.titre as title, ib.date_expire as date_fin, ib.created_at as date_creation, eb.content as content, '' FROM...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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:
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.