-
Notifications
You must be signed in to change notification settings - Fork 0
HTTP
1xx Informational 2xx Success 3xx Redirection 4xx Client error 5xx Server error
Status code 200 OK GET and HEAD responses 201 Created POST responses 204 No content PUT or PATCH responses 301 Moved permanently URL has changed permanently, for example a domain change 304 Not Modified For validation caching, as a response of If-None-Match or If-Modified-Since headers 400 Bad request For example, bad parameters sent by the client 403 Forbidden User is not authorized to access to the resource 404 Not found The resource does not exist 405 Method Not Allowed The HTTP method is not accepted. For example, the TRACE method is refused by most servers 500 Internal Server Error General error in the server
The HTTP protocol is stateless, that’s why additional tools are needed to maintain the session, like cookies or querystring parameters. It is also a text-based protocol, which makes it easier to debug but also less efficient.
There are two important concepts for HTTP methods: idempotency and safety. Safe methods are the ones that do not modify resources (or at least they shoudn’t), such as GET, HEAD and OPTIONS. In the other hand, idempotent methods can be called several times without different outcomes. For example, POST is not idempotent, as it creates a new resource in each call. In the other hand, PUT is idempotent, as it modifies a resource providing the newly-updated representation of the original resource, so calling it multiple times will end up with the same representation as the first call. GET, HEAD, OPTIONS, PUT and DELETE are idempotent methods.
By default, HTTP requests are sent to the port 80, and HTTPS ones to 443.
In each request, the browser fills the Accept-Language header with the languages configured by the user. It may also contain a parameter indicating the priority, for example:
Accept-Language:es,en;q=0.8,en-US;q=0.6
The HEAD method is identical to GET, except that the server must return an empty body. The metainformation contained in the HTTP headers should also be identical to the ones returned for the GET method. The HEAD method is useful for testing links.
– Safe methods should not modify resources. GET,HEAD and OPTIONS are safe methods. – Idempotent methods can be called several times without different outcomes. That is, the side-effects of several identical requests is the same as for a single request. GET, HEAD, OPTIONS, PUT and DELETE are idempotent methods. – Symfony removes the response body for HEAD requests. – Some browsers only accept the GET and POST methods. Symfony uses the _method parameter as a workaround.
Status codes – Classes
- 1xx class: Informational
- 2xx class: Success
- 3xx class: Redirection HTTP
- 4xx class: Client error
- 5xx class: Server error – The HttpKernel provides exceptions for common HTTP errors that generate the proper status code.
- Accept-Language is used to communicate the language preferences of the user, ordered by priority.
- Host specifies the host (domain) and the port number.
- Accept-Encoding: gzip is sent by clients that support GZIP compression.
- In compressed responses, Content-Encoding is used to inform the client about the compression algorithm used, while Content-Type contains the original content type before compressed.