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
+29-11Lines changed: 29 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -514,26 +514,44 @@ stages:
514
514
In this stage, you'll add support for handling multiple concurrent connections.
515
515
516
516
- slug: "ap6"
517
-
name: "Get a file"
517
+
name: "Return a file"
518
518
difficulty: medium
519
519
description_md: |-
520
-
In this stage, your server will need to return the contents of a file.
521
-
522
-
The tester will execute your program with a `--directory` flag like this:
520
+
In this stage, you'll implement the `/files/{filename}` endpoint, which returns a requested file to the client.
523
521
522
+
### Tests
523
+
The tester will execute your program with a `--directory` flag. The `--directory` flag specifies the directory where the files are stored, as an absolute path.
524
524
```
525
-
./your_server.sh --directory <directory>
525
+
$ ./your_server.sh --directory /tmp/
526
526
```
527
527
528
-
It'll then send you a request of the form `GET /files/<filename>`.
528
+
The tester will then send two `GET` requests to the `/files/{filename}` endpoint on your server.
529
529
530
-
If `<filename>` exists in `<directory>`, you'll need to respond with a 200 OK response. The
531
-
response should have a content type of `application/octet-stream`, and it should contain the contents of the
532
-
file as the body.
530
+
#### First request
531
+
The first request will ask for a file that exists in the files directory:
532
+
```
533
+
$ echo -n 'Hello, World!' > /tmp/foo
534
+
$ curl -i http://localhost:4221/files/foo
535
+
```
533
536
534
-
If the file doesn't exist, return a 404.
537
+
Your server must respond with a `200` response that contains the following parts:
538
+
- `Content-Type` header set to `application/octet-stream`.
539
+
- `Content-Length` header set to the size of the file, in bytes.
0 commit comments