HTTP Flashcards

1
Q

Header: ‘Accept-Language’

A

The Accept-Language request HTTP header advertises which languages the client is able to understand, and which locale variant is preferred. Using content negotiation, the server then selects one of the proposals, uses it and informs the client of its choice with the Content-Language response header. Browsers set adequate values for this header according their user interface language.

This header is a hint to be used when the server has no way of determining the language via another way, like a specific URL, that is controlled by an explicit user decision. It is recommended that the server never overrides an explicit decision. The content of the Accept-Language is often out of the control of the user (like when traveling and using an Internet Cafe in a different country); the user may also want to visit a page in another language than the locale of their user interface.

If the server cannot serve any matching language, it can theoretically send back a 406 (Not Acceptable) error code. But, for a better user experience, this is rarely done and more common way is to ignore the Accept-Language header in this case.

Syntax
Accept-Language:
Accept-Language:
Accept-Language: *

// Multiple types, weighted with the quality value syntax:
Accept-Language: fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7, *;q=0.5
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Header: Accept

A

The Accept header lists the MIME types of media resources that the agent is willing to process. It is comma-separated lists of MIME types, each combined with a quality factor, a parameter indicating the relative degree of preference between the different MIME types.

The Accept header is defined by the browser, or any other user-agent, and can vary according to the context, like fetching an HTML page or an image, a video, or a script: It is different when fetching a document entered in the address bar or an element linked via an <img></img>, or element. Browsers are free to use the value of the header that they think is the most adequate; an exhaustive list of default values for common browsers is available.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Header: ‘Accept-Charset’

A

The Accept-Charset request HTTP header advertises which character set the client is able to understand. Using content negotiation, the server then selects one of the proposals, uses it and informs the client of its choice within the Content-Type response header. Browsers usually don’t set this header as the default value for each content type is usually correct and transmitting it would allow easier fingerprinting.

If the server cannot serve any matching character set, it can theoretically send back a 406 (Not Acceptable) error code. But, for a better user experience, this is rarely done and the more common way is to ignore the Accept-Charset header in this case.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Header: Vary

A

The Vary HTTP response header determines how to match future request headers to decide whether a cached response can be used rather than requesting a fresh one from the origin server. It is used by the server to indicate which headers it used when selecting a representation of a resource in a content negotiation algorithm.

The Vary header should be set on a 304 Not Modified response exactly like it would have been set on an equivalent 200 OK response.

Header type:	Response header
Forbidden header name:	no
Syntax: 
Vary: *
Vary: , , ...
Directives
*
Each request for a URL is supposed to be treated as a unique and uncacheable request. A better way to indicate this is to use Cache-Control: private, which is clearer to read and also signals that the object shouldn't be stored ever.

A comma-separated list of header names to take into account when deciding whether or not a cached response can be used.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Status Code:

100 Continue

A

This interim response indicates that everything so far is OK and that the client should continue with the request or ignore it if it is already finished.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Status Code:

101 Switching Protocol

A

This code is sent in response to an Upgrade request header by the client, and indicates the protocol the server is switching too.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Status Code:

103 Processing

A

This code indicates that the server has received and is processing the request, but no response is available yet.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Status Code:

200 OK

A

The request has succeeded. The meaning of a success varies depending on the HTTP method:
GET: The resource has been fetched and is transmitted in the message body.
HEAD: The entity headers are in the message body.
POST: The resource describing the result of the action is transmitted in the message body.
TRACE: The message body contains the request message as received by the server

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Status Code:

201 Created

A

The request has succeeded and a new resource has been created as a result of it. This is typically the response sent after a PUT request.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Status Code:

202 Accepted

A

The request has been received but not yet acted upon. It is non-committal, meaning that there is no way in HTTP to later send an asynchronous response indicating the outcome of processing the request. It is intended for cases where another process or server handles the request, or for batch processing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Status Code:

203 Non-Authoritative Information

A

This response code means returned meta-information set is not exact set as available from the origin server, but collected from a local or a third party copy. Except this condition, 200 OK response should be preferred instead of this response.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Status Code:

204 No Content

A

There is no content to send for this request, but the headers may be useful. The user-agent may update its cached headers for this resource with the new ones.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Status Code:

205 Reset Content

A

This response code is sent after accomplishing request to tell user agent reset document view which sent this request.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Status Code:

206 Partial Content

A

This response code is used because of range header sent by the client to separate download into multiple streams.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Status Code:

300 Multiple Choice

A

The request has more than one possible responses. User-agent or user should choose one of them. There is no standardized way to choose one of the responses.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Status Code:

301 Moved Permanently

A

This response code means that URI of requested resource has been changed. Probably, new URI would be given in the response.

17
Q

Status Code:

302 Found

A

This response code means that URI of requested resource has been changed temporarily. New changes in the URI might be made in the future. Therefore, this same URI should be used by the client in future requests.

18
Q

Status Code:

303 See Other

A

Server sent this response to directing client to get requested resource to another URI with an GET request.

19
Q

Status Code:

304 Not Modified

A

This is used for caching purposes. It is telling to client that response has not been modified. So, client can continue to use same cached version of response.

20
Q

Status Code:

307 Temporary Redirect

A

Server sent this response to directing client to get requested resource to another URI with same method that used prior request. This has the same semantic than the 302 Found HTTP response code, with the exception that the user agent must not change the HTTP method used: if a POST was used in the first request, a POST must be used in the second request.

21
Q

Status Code:

308 Permanent Redirect

A

This means that the resource is now permanently located at another URI, specified by the Location: HTTP Response header. This has the same semantics as the 301 Moved Permanently HTTP response code, with the exception that the user agent must not change the HTTP method used: if a POST was used in the first request, a POST must be used in the second request.