HTTP by Hand: Talking to the Orders API
Harpreet says store 3 shows paneer in stock but riders cannot find any. Before blaming the data, learn to talk to the API yourself: read whole responses, ask with query strings, POST an order, make the API refuse one — and finally speak HTTP with no client at all.
- Beginner
- 42 min
- Networking
- HTTP
- curl
- Kestrel
Overview
Harpreet Kaur files a ticket: "Store 3 shows paneer in stock but the riders can't find any." Simran's advice: before you blame the data, take the app out of the loop and talk to the API yourself.
HTTP is a plain-text conversation: a request line, headers, a blank line, a body — and back comes a status line, headers and a body. In this lab you speak it with curl, then with nothing but bash: compare a response from the API with the same response through nginx, query the catalogue for store 3, place a real order with POST, make the API say no in two different ways, and finally type an HTTP request onto a raw TCP connection and watch nginx log a visitor with no name.
What you will learn
- Read a complete HTTP response — status line, headers, body — with
curl -i - Pass query-string parameters and read JSON with
jq - Send a JSON body with POST and recognise 201 Created
- Tell 400, 409 and 5xx apart and know what a client should do with each
- Send a raw HTTP request over bash's
/dev/tcp
Before you start
- You can run commands in a Linux shell
- No prior HTTP knowledge needed
Tasks
- 01Read a whole response
- 02Ask a question with a query string
- 03Place an order with POST
- 04Make the API say no
- 05Speak HTTP with no client at all