/getPageSource returns the page and nothing else. Set get_headers=true and the answer becomes JSON that also carries what the target answered with: its status code, the URL the request ended on after redirects, its response headers, and the request headers that were actually sent for that page.
Use it when you are moving from plain proxies and your code reads headers: caching (etag, last-modified, cache-control), redirects, set-cookie, content type, rate-limit headers, or to check which browser identity a page was fetched with.
Request
Response shape
Header names are lowercase. A header the target sent more than once is joined with
", ", except set-cookie, which is always a list (cookie values can contain commas).
The headers describe the target’s response. content-length and content-encoding are the target’s transfer, not the size or encoding of html as we deliver it. HTTP/2 pseudo-headers (:authority, :path) are left out, so an HTTP/2 request has no host entry.
When the page reloaded itself in the browser before it was ready (a bot check that clears and reloads, a script redirect), the browser reports only the request headers the page itself set for that reload. request_headers then lacks the ones its network layer adds, such as cookie and accept-encoding.
Some pages are rendered by a path that does not expose headers. Then
headers, request_headers and final_url are null and status_code is the status we answered with. The page itself is the same.Pages the target answers with an error
When the target’s own answer is the result - a page that does not exist (404, 410), or the target’s own 401, 451 or 5xx page - the JSON is the same and status_code is the target’s status. See errors for which of these are billed.
Combining with other parameters
get_cookies=trueaddscookies, the target’s cookies from the session, to the same JSON. See cookies and sessions.parsed_data=trueaddsdata, the extracted fields. See parsed data.
get_headers cannot be combined with markdown, list_elements or capture_xhr: each returns its own format, so such a request answers 422 and is not billed.
A get_headers call is billed like the same call without it.
