>_ IzzyLab

Hands-on task

This task is step 5 of the course “curl and HTTP APIs”

Send your own header

easy~3 min

A local server at http://localhost:8080/ echoes back the header it receives. Send it a request with the HTTP header X-Token: secret123 and save the response to /root/resp.txt. Without the header the server replies no token.

What you'll practise:
  • curl
  • -H
  • HTTP headers
  • request

Topic breakdown

HTTP request headers are "name: value" pairs the client uses to pass metadata to the server (authorization, content type, custom tokens). In curl you add them with -H 'Name: value', repeating the option for each header. This is how you send, for example, Authorization, Content-Type or an API's own X-* headers. The -s (silent) flag suppresses the progress bar so that only the response body ends up in the output/file.

What's checked

  1. the X-Token header got through

What it looks like