HTTP Request Header and HTTP Response Header

Hi,

I would like to know difference and similarities, uses between HTTPRequestHeader and HTTPResponseHeader. When we have to use which one. What are the important practically used mentods.


Are  HTTP 1.1 Request/Response Headers are different from  HTTP Request/Response Header?
Please advise.
Currently HTTP is being used or HTTP1.1?

Do we ever practically need to use this Header stuff?

Any links resources ideas highly appreciated. Thanks in advance
LVL 7
gudii9Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
There have been 3 versions of the HTTP protocol, 0.9, 1.0 and 1.1.  They each support slightly different methods.

An HTTP Request Header is Always sent by the client / browser to the server to get a response.  The HTTP Response Header is Always sent by the server or code on the server to tell the client what is being returned to it.  Only the client send the HTTP Request Header.  Only the server sends the HTTP Response Header.

For things like HTML pages that the web server does on it's own, the web server sends the HTTP Response Header.  If your program code is returning a file to the client, it will probably have to send an appropriate HTTP Response Header itself.  

On one of my own pages, I use PHP to respond to a javascript request.  Since I am creating the javascript in my PHP file, I have to send the appropriate HTTP Response Header that identifies the returned data as "text/javascript" so the browser will know what to do with it.  In general, if you are using a program to send a file to the client, you will have to provide the HTTP Response Header first.  If the web server is returning one of the standard types, you don't have to add anything because the web server has a list of content and file types (MIME Types) and the standard responses to send with them.

http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mccarlIT Business Systems Analyst / Software DeveloperCommented:
Headers (both request and response) are used to provide additional information about the request or response. For example, the content of the response from a web server might be the actual HTML page that should be rendered in the browser, but the web server might also want to return additional information, like the number of bytes the client should expect, or when that information might expire and need to be updated, etc. This additional info is sent as response headers.

And the same for the request, if you are uploading a file to a web server then the content of that file is what is sent as the content of the request to store that file, but you might also want to send additional information, such as the file name and file type, etc. This is sent as request headers.

Similarities? Well they are of the same format, ie. "HeaderName: HeaderValue" and separated by CR/LF and they are sent first before the actual content of the request/response.

Differences? Just in the direction that they are sent (request headers are sent by the clinet/browser TO the web server and response headers are sent FROM the web server) and the purpose they are used for.


As for HTTP v1.0 versus HTTP v1.1, there is no difference in the format or location of the headers but there are a number of differences in which particular headers are required and which headers might be used by servers/browsers, etc. The differences are too long and detailed for me to repeat here, so if you need more info than this you should refer to the specs for HTTP or google "http v1.0 vs v1.1" for some summary information.

HTTP/1.1 is the most common these days but there are definitely still situations where HTTP/1.0 is used. There is some backwards compatibility/version negotiation built in there but to give any more useful information depends on if you are implementing something on the client side (that needs to connect to standards based servers) or the server side (which needs to be accessed from standards based clients/browsers).

Do we ever practically need to use this Header stuff?
Most definitely, YES!
0
gudii9Author Commented:
>>For things like HTML pages that the web server does on it's own, the web server sends the HTTP Response Header.  If your program code is returning a file to the client, it will probably have to send an appropriate HTTP Response Header itself.  

Can you please elaborate on above sentence.



>>>if you are implementing something on the client side (that needs to connect to standards based servers) or the server side (which needs to be accessed from standards based clients/browsers).


Can you please elaborate on client side implementation vs server side implementation  and how that effect choise between http1.1/1.0

Please advise
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

mccarlIT Business Systems Analyst / Software DeveloperCommented:
I'll allow Dave to elaborate on the sentence that you have queries on. As for what I was saying regarding clients and servers, all I was trying to do was to ask you why you are interested in this; are you writing code that will act as a client? Or are you writing code that will act as a server? If you're not actually writing code, and are just asking about this out of interest then don't worry about what I was asking, it should be enough just to know that there are provisions in the HTTP standards so that clients/servers of differing versions can still generally work together.
0
Dave BaldwinFixer of ProblemsCommented:
If your program is returning a file to your client that has a different MIME or Content Type than your program, you must send an appropriate Content-Type header.  The standard Content-Type is "text/html".  If your program is sending a JPG image to the client, you must first send a "Content-Type: image/jpeg" so the browser will know what to do with the file.
0
Dave BaldwinFixer of ProblemsCommented:
It appears that the client requests the HTTP version.  I don't know what happens if the server doesn't support it.  But then, HTTP/1.1 has been the current standard for a long time now since June 1999.

All of this information is in the Wikipedia article I linked above.
0
gudii9Author Commented:
>>If your program is returning a file to your client that has a different MIME or Content Type than your program, you must send an appropriate Content-Type header.



your program--> means java program like java servlet running on server like tomcat server right???

 client --->means the browser right like IE or Mozilla??


you must send an appropriate Content-Type header---->you mean to say the server must send right. Please advise
0
Dave BaldwinFixer of ProblemsCommented:
You have everything right except the last statement.  If you are using your program like *.jsp to send a file that is *.jpg to the client then your *.jsp program must send the "image/jpeg" content header itself.  Since the actual file does not match the 'type' of your *.jsp program file, you must send the correct header yourself.  That is because the server does not know that you are sending something other than a *.jsp file.
0
gudii9Author Commented:
>>>you must send the correct header yourself.


In the ResponseHeader right?


If yes then i understood about ResponseHeader.

In what situations we use RequestHeaders?

Please advise.
0
Dave BaldwinFixer of ProblemsCommented:
Clients send Request Headers.  Are you writing code to be used as a client that makes Requests to another server?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.