HTTP

Hypertext Transport Protocol is a very basic protocol as we saw earlier - implementing a web server in 30 lines of code shows how easy it can be. However, there is actually a remarkable degree of complexity behind it allows for a lot of flexibility, much of which lies in the plethora of status codes it has available.

These status codes are all three digits, and can be broken down into the following groups:

  • 1xx: Informational - Request received, continuing process

  • 2xx: Success - The action was successfully received, understood, and accepted

  • 3xx: Redirection - Further action must be taken in order to complete the request

  • 4xx: Client Error - The request contains bad syntax or cannot be fulfilled

  • 5xx: Server Error - The server failed to fulfil an apparently valid request

As you can see, 400-level errors are client errors - the client did not send the right kind of request, requested a file that does not exist, etc. The most common error, 404, is a client error meaning, "Object not found" - the user typed in a URL that did not exist. Also in the 400 series is 401, "Unauthorized", where the user did not provide the correct credentials to view the content.

In order to be able to manipulate HTTP skilfully, you need a list of the most important HTTP status codes - and there they are:

200

Request accepted; response attached

201

Request accepted; new object created on server

206

Request accepted; partial content attached

301

Content moved permanently

400

Bad request; client sent something bad

401

Unauthorised; client sent credentials, but they were rejected

403

Forbidden; server understood the request, but refuses to comply

404

Not found; URL requesting non-existent object was sent

500

Internal server error; the server encountered something internally (not from the client) that prevented it from fulfilling the request. This usually means the server or a module such as PHP is configured incorrectly and/or crashing.

 

Next chapter: Sending custom headers >>

Previous chapter: Host and IP resolution

Jump to:

 

Home: Table of Contents

Follow us on Identi.ca or Twitter

Username:   Password:
Create Account | About TuxRadar