HTTP headers

COMP 426 w02.00

Agenda

  1. Pearl Hacks
  2. Your new best friend, curl
  3. What do headers do?
  4. How can we see them?
    1. curl
    2. Inspector
  5. Requests and responses
  6. What do statuses tell us?

Request header


> HEAD / HTTP/2
> Host: comp426.johndmart.in
> user-agent: curl/7.74.0
> accept: */*
>
					

Response header


< HTTP/2 200 
< date: Tue, 25 Jan 2022 18:49:37 GMT
< content-type: text/html; charset=utf-8
< last-modified: Tue, 25 Jan 2022 16:35:00 GMT
< access-control-allow-origin: *
< expires: Tue, 25 Jan 2022 17:35:56 GMT
< cache-control: max-age=600
< x-proxy-cache: MISS
< x-github-request-id: E7F0:6B6C:80FEB:1FCA70:61F032A4
< via: 1.1 varnish
< age: 0
< x-served-by: cache-pdk17829-PDK
< x-cache: HIT
< x-cache-hits: 1
< x-timer: S1643136577.126331,VS0,VE20
< vary: Accept-Encoding
< x-fastly-request-id: 58ffa7ae5a2fed06a397539795fed754f81b9982
< cf-cache-status: DYNAMIC
< expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
< report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=lL9LtTFFVGIwxMaBbYyrYA67HSdqQvpBHfQbEUkUFPKcG27W8kPWdLG98RfeOc7vCopCi%2FreyU10SAWrB1EgGTyvR5L7rlf6r67zZG88jWe2itzRGf9QhErwgL6pnNinIDkae%2FtpZw%3D%3D"}],"group":"cf-nel","max_age":604800}
< nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
< server: cloudflare
< cf-ray: 6d33aeb6db478d4c-ATL
< alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400
					

Status Codes


100		Information
200		Success
300		Redirection
400		Client error
500		Server error
					

404


$ curl -I https://comp426.johndmart.in/hello
< HTTP/2 404 
< date: Tue, 25 Jan 2022 19:08:52 GMT
< content-type: text/html; charset=utf-8
< access-control-allow-origin: *
< x-proxy-cache: MISS
< x-github-request-id: 6EC0:3A44:1B027E:2F6CEF:61F04AC4
< via: 1.1 varnish
< age: 0
< x-served-by: cache-iad-kiad7000119-IAD
< x-cache: MISS
< x-cache-hits: 0
< x-timer: S1643137732.433783,VS0,VE12
< vary: Accept-Encoding
< x-fastly-request-id: d1a6e37b628db4b212f92460742c7f3731e2424d
< cf-cache-status: DYNAMIC
< expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
< report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=V9pBv6fZCr6rjln5QEGnnw9cZWa38kqLWIORCzsnGvMcVa3Ft%2F7nN9ob%2FzA%2BiN4M19V%2BwAhA8bwZtxgFqNTn7FP5EOPUHUyKnnxp%2B0WbHDCDPE3p%2BM50vifO%2BXF3jviSjHBTMH1R6Q%3D%3D"}],"group":"cf-nel","max_age":604800}
< nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
< server: cloudflare
< cf-ray: 6d33caeb99c781cf-IAD
< alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400
					
Demo