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
@@ -794,39 +794,41 @@ stages:
794
794
name: "Gzip compression"
795
795
difficulty: medium
796
796
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.
798
798
799
799
### Tests
800
800
801
801
The tester will execute your program like this:
802
-
803
-
```bash
804
-
./your_server.sh
802
+
```
803
+
$ ./your_server.sh
805
804
```
806
805
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`.
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.
821
817
822
818
```
823
819
HTTP/1.1 200 OK
824
820
Content-Encoding: gzip
825
821
Content-Type: text/plain
826
822
Content-Length: 23
827
823
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
829
827
```
830
828
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.
831
833
marketing_md: |
832
834
In this stage, you'll add support for encoding the response body using `gzip`.
0 commit comments