Skip to content

Commit f3bded4

Browse files
committed
Update stage 11 instructions
1 parent dea1d6a commit f3bded4

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

course-definition.yml

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -794,39 +794,41 @@ stages:
794794
name: "Gzip compression"
795795
difficulty: medium
796796
description_md: |
797-
In this stage, you'll add support for returning responses compressed using gzip.
797+
In this stage, you'll add support for [`gzip` compression](https://www.gzip.org/) to your HTTP server.
798798
799799
### Tests
800800
801801
The tester will execute your program like this:
802-
803-
```bash
804-
./your_server.sh
802+
```
803+
$ ./your_server.sh
805804
```
806805
807-
It'll then send an HTTP `GET` request to the `/echo/<a-random-string>` endpoint. In the request, it'll include an Accept-Encoding header like: `Accept-Encoding: gzip`.
808-
As an example, here's a request you might receive:
809-
806+
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`.
810807
```
811-
GET /echo/foo HTTP/1.1
812-
Host: localhost:4221
813-
User-Agent: curl/7.64.1
814-
Accept-Encoding: gzip
808+
$ curl -v -H "Accept-Encoding: gzip" http://localhost:4221/echo/abc | hexdump -C
815809
```
816810
817-
Your server must respond with a `200 OK` response. The response should have a `Content-Encoding: gzip` header present. The response body should be the random string sent in the request, gzip encoded. And the `Content-Length` header should be the length of the gzip encoded data.
818-
Here's the response you're expected to send back:
819-
If the raw string was `foo`, the hex encoded data would be `gzip-encoded-data`
820-
Hex representation of it would be `1f8b08008c643b6602ff4bcbcf07002165738c03000000`
811+
Your server's response must contain the following:
812+
- `200` response code.
813+
- `Content-Type` header set to `text/plain`.
814+
- `Content-Encoding` header set to `gzip`.
815+
- `Content-Length` header set to the size of the compressed body.
816+
- Response body set to the `gzip`-compressed `str` parameter.
821817
822818
```
823819
HTTP/1.1 200 OK
824820
Content-Encoding: gzip
825821
Content-Type: text/plain
826822
Content-Length: 23
827823
828-
gzip-encoded-data
824+
1F 8B 08 00 00 00 00 00 // Hexadecimal representation of the response body
825+
00 03 4B 4C 4A 06 00 C2
826+
41 24 35 03 00 00 00
829827
```
830828
829+
### Notes
830+
831+
- To check that your compressed body is correct, you can run `echo -n <uncompressed-str> | gzip | hexdump -C`.
832+
- It's normal for a very short string like `abc` to increase in size when compressed.
831833
marketing_md: |
832834
In this stage, you'll add support for encoding the response body using `gzip`.

0 commit comments

Comments
 (0)