From 35ec1589b75eeb2035aa2793a80a8d769547417b Mon Sep 17 00:00:00 2001 From: Victor Ma Date: Fri, 14 Jun 2024 16:12:31 -0400 Subject: [PATCH] Backup --- course-definition.yml | 54 +++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 35 deletions(-) diff --git a/course-definition.yml b/course-definition.yml index e456bf4..01631a5 100644 --- a/course-definition.yml +++ b/course-definition.yml @@ -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 @@ -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 | 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.