Responses

Aside from the first response line, called the status line, responses are formatted very similarly to requests. While different headers are used in requests and responses, they are formatted the same way. A blank line separates the headers and the body in both requests and responses. The body may be absent in either depending on what the request operation is. Below is an example response.

HTTP/1.0 200 OK
Date: Mon, 21 Jul 2008 02:32:52 GMT
Server: Apache
X-Powered-By: PHP/5.2.5
Cache-Control: private, s-maxage=0, max-age=0, must-revalidate
Content-Language: en
Last-Modified: Mon, 21 Jul 2008 02:06:27 GMT
Content-Length: 53631
Content-Type: text/html; charset=utf-8
Connection: close

[body...]

Aside from headers, the main difference in content between requests and responses is in the contents of the request line versus the status line.

  • 1.0 is the minimum HTTP protocol version under which the response can be correctly interpreted by the client.
  • 200 is a response status code and OK is its corresponding human-readable description. ft indicates the result of the server attempting to process the request, in this case that the request was successful.

Status codes are divided into five classes distinguished by the first digit of the code. Below is a brief summary of each class. See section 10 of RFC 2616 for further descriptions of circumstances under which specific status codes may be received.

  • 1xx Informational: Request received, continuing process.
  • 2xx Success: Request received, understood, and accepted.
  • 3xx Redirection: Client must take additional action to complete the request.
  • 4xx Client Error: Request could not be fulfilled because of a client issue.
  • 5xx Server Error: Request was valid but the server failed to process it.

Moving right along, let us examine headers in more depth.


© HTTP — Web Scraping

>>> Back to TABLE OF CONTENTS <<<
Category: Article | Added by: Marsipan (30.08.2014)
Views: 382 | Rating: 0.0/0
Total comments: 0
avatar