Skip to content

Commit

Permalink
Backup
Browse files Browse the repository at this point in the history
  • Loading branch information
vic-ma committed Jun 14, 2024
1 parent 90b7916 commit 35ec158
Showing 1 changed file with 19 additions and 35 deletions.
54 changes: 19 additions & 35 deletions course-definition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,7 @@ stages:
name: "Read header"
difficulty: very_easy
description_md: |-
In this stage, you'll add support for `Accept-Encoding` headers that contain multiple compression schemes.
### Multiple compression schemes
A client can specify that it supports multiple compression schemes by setting `Accept-Encoding` to a comma-separated list:
```
Accept-Encoding: encoding-1, encoding-2, encoding-3
```
For this extension, assume that your server only supports the `gzip` compression scheme.
For this stage, you don't need to compress the body. You'll implement compression in a later stage.
In this stage, you'll add support for [`gzip` compression](https://www.gzip.org/) to your HTTP server.
### Tests
Expand All @@ -46,38 +35,33 @@ stages:
$ ./your_server.sh
```
The tester will then send two `GET` requests to the `/echo/{str}` endpoint on your server.
#### First request
For the first request, the `Accept-Encoding` header will contain `gzip`, along with some invalid encodings:
Then, the tester will send a `GET` request to the `/echo/{str}` endpoint on your server. The request will contain an `Accept-Encoding` header that includes `gzip`.
```
$ curl -v -H "Accept-Encoding: invalid-encoding-1, gzip, invalid-encoding-2" http://localhost:4221/echo/abc
$ curl -v -H "Accept-Encoding: gzip" http://localhost:4221/echo/abc | hexdump -C
```
Your server's response must contain this header: `Content-Encoding: gzip`.
```javascript
Your server's response must contain the following:
- `200` response code.
- `Content-Type` header set to `text/plain`.
- `Content-Encoding` header set to `gzip`.
- `Content-Length` header set to the size of the compressed body.
- Response body set to the `gzip`-compressed `str` parameter.
```
HTTP/1.1 200 OK
Content-Type: text/plain
Content-Encoding: gzip
Content-Type: text/plain
Content-Length: 23
// Body omitted.
1F 8B 08 00 00 00 00 00 // Hexadecimal representation of the response body
00 03 4B 4C 4A 06 00 C2
41 24 35 03 00 00 00
```
#### Second request
For the second request, the `Accept-Encoding` header will only contain invalid encodings:
```
$ curl -v -H "Accept-Encoding: invalid-encoding-1, invalid-encoding-2" http://localhost:4221/echo/abc
```
### Notes
Your server's response must not contain a `Content-Encoding` header:
```javascript
HTTP/1.1 200 OK
Content-Type: text/plain
// Body omitted.
```
- To check that your compressed body is correct, you can run `echo -n <uncompressed-str> | gzip | hexdump -C`.
- It's normal for a very short string like `abc` to increase in size when compressed.
marketing_md: |-
In this stage, we'll do XYZ.
Expand Down

0 comments on commit 35ec158

Please sign in to comment.