Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I understand what HTTP requests look like from the client side, but what I am curious about is what methods does the server use to serve pages back?

Client:

GET /index.html HTTP/1.1
Host foo.com:80

Server:

Does it perform an HTTP PUT of index.html ?  If not, then what?  Are HTTP methods used both ways?

If the response does not use HTTP methods, then is it simply a TCP packet (or several) that contain the payload? Is there any HTTP protocol specific information in the packets?

share|improve this question

closed as off-topic by Matthew Ife, Jenny D, Cristian Ciupitu, Tom O'Connor Jul 7 at 11:34

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must demonstrate a minimal understanding of the problem being solved. Try including attempted solutions, why they didn't work, and the expected results. See How can I ask better questions on Server Fault? for further guidance." – Matthew Ife, Jenny D, Cristian Ciupitu, Tom O'Connor
If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Have you read the relevant RFCs? –  Michael Hampton Jul 4 at 16:02
    
No, I havent read the RFCs top to bottom. I have read parts. –  usedTobeaMember Jul 4 at 16:23
    
I looked up the answer in the RFC and confirmed my suspicion that methods are not used, but I was hoping for more insight into the reasoning, which is why I asked it here. Based on your comment, I can only assume people will be more focused on the fact that the answer can be looked up online, than trying to provide context to the answer with additional information, so I'll just answer it myself. –  usedTobeaMember Jul 4 at 16:34

3 Answers 3

up vote 1 down vote accepted

An HTTP request can be sent using one of the following methods:

> Get()

Issues the HTTP GET request. This method causes the web server to return the page requested.

> Head()

Issues the HTTP HEAD request. This method causes the web server to return just the headers of the response and none of the body.

> Post()

Issues the HTTP POST request. Use this method to send data to the web server such as the results of a form, or upload a file.

> Put()

Issues the HTTP PUT request. Use this method to upload data to the web server. PUT requests are not common.

> Send()

Sends the specified type of HTTP request to the server.


After receiving and interpreting a request message, a server responds with an HTTP response message.

   Response      = Status-Line               ; Section 6.1
                   *(( general-header        ; Section 4.5
                    | response-header        ; Section 6.2
                    | entity-header ) CRLF)  ; Section 7.1
                   CRLF
                   [ message-body ]          ; Section 7.2

The response information was quoted from the following site: W3.org

share|improve this answer
1  
Thanks for answering the question asked. It is surprisingly hard to have that happen sometimes. –  usedTobeaMember Jul 4 at 16:59
    
@usedTobeaMember You're welcome. A +1 on my answer would be great, thanks! –  injector Jul 4 at 17:02
1  
The notation you use (Get() etc.) looks like you are referring to a certain programming language you do not mention. Also, there is no SEND method in HTTP, and the DELETE, CONNECT, OPTIONS and TRACE methods are missing (see RFC 7231). But this is irrelevant to the question anyway, only the last part gives the (correct) answer. You should have elaborated on the different status codes. ;-) –  Dubu Jul 5 at 6:08

I will answer my own question. No, HTTP methods are only used in request headers. Status codes are used in response headers. I know I have viewed headers on both sides and should have been able to say this without looking it up, but I wasn't sure. The benefit to asking a question like this (one that can be fairly easily looked up) in a useful forum is that sometimes you learn something additional, or get some perspective that helps deepen your understanding.

share|improve this answer
    
I answered your question, but I think I was too late. –  injector Jul 4 at 16:51
    
Nope, not too late, I gave it to you. Thanks. –  usedTobeaMember Jul 7 at 18:50

First

Your request have to match HTTP protocol.

IE your header have to be terminated by an empty line:

GET /index.html HTTP/1.1
Host foo.com:80
 

Nota: Each line have to teminate by CRLF, not only LF nor only CR:

00000000  47 45 54 20 2f 20 48 54  54 50 2f 31 2e 30 5c 72  |GET / HTTP/1.0\r|
00000010  5c 6e 48 6f 73 74 3a 20  66 6f 6f 2e 63 6f 6d 3a  |\nHost: foo.com:|
00000020  38 30 5c 72 5c 6e 5c 72  5c 6e 0a                 |80\r\n\r\n.|

The server's answer could match same form:

Header - Empty line - Body

So you could drop the header by using sed, for sample:

nc foo.com 80 <<<$'GET / HTTP/1.0\r\nHost: foo.com:80\r\n\r' |
    sed '1,/^\r\?$/d' > index-of-foo.com.html

Or dump only the header:

nc foo.com 80 <<<$'GET / HTTP/1.0\r\nHost: foo.com:80\r\n\r' |
    sed '/^\r\?$/q'

You could find all your answer on Internet:

First referencial doc: on w3.org

Or at Wikipedia: http on wikipedia

What a method for answering?

The header of answer do contain all needed information for understanding how to deal with answer.

Essentialy, there is a Content-Type, required to tell your browser what to do with that.

The server could have to process some stuff for building his answer, but between server and client, there are only one (stupid) TCP connection.

There is nothing the server could ask the client to do...

Except interactive constructions between high level processing stack like javascript, html5 (css), java, flash or other dilbertlight.

share|improve this answer
    
I am not sure you answered my question. I am asking does a response contain HTTP methods like: GET PUT HEAD POST etc.. –  usedTobeaMember Jul 4 at 16:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.