Skip to content

Commit 16298f7

Browse files
authored
Merge pull request #78 from vic-ma/update-stage-11
Update stage 11 instructions
2 parents aec8bd0 + f3bded4 commit 16298f7

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
@@ -787,39 +787,41 @@ stages:
787787
name: "Gzip compression"
788788
difficulty: medium
789789
description_md: |
790-
In this stage, you'll add support for returning responses compressed using gzip.
790+
In this stage, you'll add support for [`gzip` compression](https://www.gzip.org/) to your HTTP server.
791791
792792
### Tests
793793
794794
The tester will execute your program like this:
795-
796-
```bash
797-
./your_server.sh
795+
```
796+
$ ./your_server.sh
798797
```
799798
800-
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`.
801-
As an example, here's a request you might receive:
802-
799+
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`.
803800
```
804-
GET /echo/foo HTTP/1.1
805-
Host: localhost:4221
806-
User-Agent: curl/7.64.1
807-
Accept-Encoding: gzip
801+
$ curl -v -H "Accept-Encoding: gzip" http://localhost:4221/echo/abc | hexdump -C
808802
```
809803
810-
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.
811-
Here's the response you're expected to send back:
812-
If the raw string was `foo`, the hex encoded data would be `gzip-encoded-data`
813-
Hex representation of it would be `1f8b08008c643b6602ff4bcbcf07002165738c03000000`
804+
Your server's response must contain the following:
805+
- `200` response code.
806+
- `Content-Type` header set to `text/plain`.
807+
- `Content-Encoding` header set to `gzip`.
808+
- `Content-Length` header set to the size of the compressed body.
809+
- Response body set to the `gzip`-compressed `str` parameter.
814810
815811
```
816812
HTTP/1.1 200 OK
817813
Content-Encoding: gzip
818814
Content-Type: text/plain
819815
Content-Length: 23
820816
821-
gzip-encoded-data
817+
1F 8B 08 00 00 00 00 00 // Hexadecimal representation of the response body
818+
00 03 4B 4C 4A 06 00 C2
819+
41 24 35 03 00 00 00
822820
```
823821
822+
### Notes
823+
824+
- To check that your compressed body is correct, you can run `echo -n <uncompressed-str> | gzip | hexdump -C`.
825+
- It's normal for a very short string like `abc` to increase in size when compressed.
824826
marketing_md: |
825827
In this stage, you'll add support for encoding the response body using `gzip`.

0 commit comments

Comments
 (0)