You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: course-definition.yml
+18-16Lines changed: 18 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -787,39 +787,41 @@ stages:
787
787
name: "Gzip compression"
788
788
difficulty: medium
789
789
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.
791
791
792
792
### Tests
793
793
794
794
The tester will execute your program like this:
795
-
796
-
```bash
797
-
./your_server.sh
795
+
```
796
+
$ ./your_server.sh
798
797
```
799
798
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`.
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.
814
810
815
811
```
816
812
HTTP/1.1 200 OK
817
813
Content-Encoding: gzip
818
814
Content-Type: text/plain
819
815
Content-Length: 23
820
816
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
822
820
```
823
821
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.
824
826
marketing_md: |
825
827
In this stage, you'll add support for encoding the response body using `gzip`.
0 commit comments