Http Flashcards

1
Q

Which HTTP-Methods exist?

A

GET - Retrieve
HEAD - Retrieve without Response-Body
POST - Action / write
PUT - Action / write
PUT - Action / write (most of the time single values)
DELETE - Remove
PURGE - Removing objects from cache?!
OPTIONS - Describe communication options for target object
TRACE - Testing trace to resource
CONNECT - Establish tunnel to the server

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

How can the maximum count of redirections can be customized for a request?

A
$response = $client->request('GET', 'https://...', [
    // 0 means to not follow any redirect
    'max_redirects' => 0,
]);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How can the used BASE_URI be randomized for an HTTP-Client?

Why would we do that?

A
$response = $client->request('GET', 'some-page', [
    'base_uri' => [
        [
            // a single random URI from this array will be used for the first request
            'https://example.com/a/',
            'https://example.com/b/',
        ],
        // non-nested base URIs are used in order
        'https://example.com/c/',
    ],
]);

Could be done to distribute the load to different nodes.

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

HTTP 100

A

Continue

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

HTTP 101

A

Switch protocol

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

HTTP 200

A

OK

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

HTTP 201

A

Created

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

HTTP 202

A

Accepted

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

HTTP 203

A

Non-Authoritative Information

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

HTTP 204

A

Empty Response

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

HTTP 205

A

Reset content (Server fulfilled request, client should reload view)

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

HTTP 300

A

Multiple Choices (target resource has multiple representations, client can choose)

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

HTTP 301

A

Moved Permanently (new route is in Location-Header, so client will be redirected)

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

HTTP 302

A

Found (Target resource temporarily located under different location)

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

HTTP 307

A

Temporary redirect to another location

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

HTTP 400

A

Bad Request (bad syntax, exceeds limitations etc)

17
Q

HTTP 401

A

Unauthorized

18
Q

HTTP 403

19
Q

HTTP 404

A

Resource not found

20
Q

HTTP 405

A

Method not allowed (E.g. when POST is requested but not allowed)

21
Q

HTTP 406

A

Not acceptable

22
Q

HTTP 408

A

Request timeout

23
Q

HTTP 413

A

Payload too large

24
Q

HTTP 415

A

Unsupported media type

25
HTTP 426
Upgrade required (server refuses to perform request using current protocol. Upgrading protocol might help)
26
HTTP 500
Internal server error
27
HTTP 501
Not implemented
28
HTTP 502
Bad Gateway (Server acts as proxy but target couldnt fulfill the request)
29
HTTP 503
Service unavailable (e.g. during maintaining)
30
HTTP 504
Gateway timeout (Server acts as proxy but target request timed out)
31
HTTP 505
HTTP-Version not supported
32
How can the users preferred language (Request Header: "Accept-Language") be used as locale automatically?
Configure it in the framework-config ``` framework: # ... set_locale_from_accept_language: true ```
33
How can we create a client to cache requests?
``` $store = new Store('/path/to/cache/storage/'); $client = HttpClient::create(); $client = new CachingHttpClient($client, $store); // this won't hit the network if the resource is already in the cache $response = $client->request('GET', 'https://example.com/cacheable-resource'); ```