HTTP

This is a README.adoc file. The original repository is located here.

Task HTTP

You can use curl or wget commands

Branch: http
Fenrir ID: http
Points: 30

Your solution must be located at http:

 ...
├─  http
│  ├─  part-1.sh
│  ├─  part-2.sh
│  ├─  part-3.sh
│  └─  part-4.sh
└─  .git

Return codes (5 points)

Create a script part-1.sh which runs an http request and parses the return code.

The script must print the answer in the format <DESC>(<CODE>)

Where DESC is a textual description of the return code:

  • SUCCESS

  • REDIRECT

  • CLIENT_ERROR

  • SERVER_ERROR

And CODE is the return code

To prevent waiting indefinitely for the response, set the maximum execution time to 5 sec.

Synopsis
./part-1.sh <URL>
Output
SUCCESS(200)

Error handling

Code Description

77

Unable to connect

88

Timeout

Questions

  • What are the 4 types of http codes?

  • Why is a timeout necessary?

POST requests (10 points)

You are to create a script part-2.sh which sends a POST request to the server and parses its response.

Request body is defined by the following class:

data class pair(
    val x : Int,
    val y : Int,
)

You must support three content types:

  • JSON

  • YAML

  • XML

XML body must be wrapped in <req version="1.1">…​</req>.

Response body is defined by this class:

data class response(
    val result : Int,
)

The script must print only one number: the value of result.

Synopsis
./part-2.sh {-x | -y | -j} <URL> <x> <y>

Options:
   -x        XML format
   -y        YAML format
   -j        JSON format
Output
56

Error handling

Is not needed. We guarantee the correctness of the input data.

Questions

  • How does the server understand which format is used?

  • Which method is used by default in curl?

  • What is the difference between GET & POST?

Redirections (10 points)

You are to create a script part-3.sh which sends a request to the server and collects all redirections.

The script must print all URLs that are encountered when resolving the server location.

Synopsis
./part-3.sh
Output
http://google.de/ http://www.google.de/ http://www.google.com/

Error handling

Is not needed. We guarantee the correctness of the input data.

Questions

  • How can the detailed information about an HTTP request be obtained?

Download files (5 points)

You are to create a script part-4.sh which downloads a file from a URL. The file must be saved to the provided directory.

Synopsis
./part-4.sh

The name is defined in the response:

< HTTP/1.1 200 OK < Accept-Ranges: bytes < Content-Disposition: attachment; filename="file.txt"

Error handling

Is not needed. We guarantee the correctness of the input data.

Questions

  • How can the filename be obtained?

  • What happens if you try accessing the URL without explicitly downloading the file?

The project is licensed under the terms of the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

© 2026-present Iwan Kalinin <koefic.cien@gmail.com>