From a URL to a response
Read a URL
Break a URL into its scheme, host, port, path, query string, and fragment so you know what each part controls.
Every HTTP request starts from a URL. If you can read one, you already know half of what the client will send.
Consider this URL:
https://flaviocopes.com:443/blog/?tag=astro&page=2#topics
It breaks into six parts:
httpsis the scheme. It tells the client to use TLS and HTTP.flaviocopes.comis the host. DNS turns this name into an IP address.443is the port. HTTPS defaults to 443, so browsers usually hide it./blog/is the path. This is the resource you are asking for.tag=astro&page=2is the query string. Extra parameters after?.topicsis the fragment. It points to a section inside the page.
The browser uses scheme, host, and port to open a connection. It sends the path and query string to the server as the request target. The fragment never leaves your machine. The server never sees #topics; the browser scrolls to that anchor after the HTML arrives.
Default ports are worth memorizing: 80 for plain HTTP, 443 for HTTPS. When you omit the port, the client picks the default for the scheme.
You can prove the fragment stays local. Run:
curl -i 'https://flaviocopes.com/blog/#topics'
The request line in verbose mode (curl -v) shows GET /blog/ with no #topics. The server responds the same as it would without the fragment.
Try this on your own project: paste a real URL from your app into the address bar, then identify each part. If you ship search or pagination, check whether those filters live in the path or the query string.
Lesson completed