# How to check request headers and their order in Chrome

> Only the server sees Chrome's request headers as they arrived, in order, with anything a proxy added. Page JavaScript never sees that copy.

Source: https://mosaicbrowser.com/blog/check-request-headers-order

## What a header echo shows that a fingerprint page doesn't

Only the server sees Chrome's request headers as they arrived, in order, with anything a proxy added. Page JavaScript never sees that copy.

![The copy of the request only the server sees, beside a screenshot: a Mosaic leak test: every surface a site reads, checked from inside the profile page](https://mosaicbrowser.com/covers/check-request-headers-order.webp)

The only complete copy of Chrome's request headers, in order, is on the server that received them, so that is where you check. Chrome's network stack adds `Sec-CH-UA`, `Accept-Encoding` and the rest after a script has asked for a URL, and a proxy writes `Via` or `X-Forwarded-For` somewhere between your machine and the site. A script on the page sees neither. An echo service, a server that prints what it received back into the response body, is how you get to look.

Most rows on our Detection tests screen are fingerprint pages like CreepJS and BrowserLeaks, reading `navigator`, canvas and fonts from inside the page. One row, id `httpbin-headers`, named Header echo, is there for the case those pages are blind to.

## Why a fingerprint page cannot see a proxy's headers

Script gets the response and whatever headers it set itself on the `Request` object. The lines Chrome writes on the way out never come back to it, and a proxy two hops away is further out of reach still.

When a fingerprint site does print "your headers", its server copied them into the page, which makes it an echo service with nicer styling. A site that never does this cannot see anything in the next section.

## The four names our Header echo row looks for

The extractor in `run-detection-tests.mjs` loads `https://httpbin.org/headers`, reads `document.body.innerText`, and reports `leaked:` followed by the names if any of these four appear as a quoted JSON key:

- `Via`. RFC 9110 says a proxy MUST send it in each message it forwards, so an HTTP proxy that follows the standard announces itself.
- `X-Forwarded-For`. Not in any RFC, and the most common way a proxy passes the client's address along.
- `Forwarded`. The standard form of the same thing, from RFC 7239, as in `Forwarded: for=192.0.2.60`.
- `Proxy-Connection`. A header meant for the proxy alone. If one reaches the site, a proxy passed the browser's request on without cleaning it.

None of this happens on an `https://` page through an honest proxy. Chrome opens a connection through the proxy with CONNECT, and the request travels inside it as TLS, which the proxy forwards without being able to read a byte. Plain `http://` requests and proxies that decrypt traffic with a certificate you installed are where these headers appear ([what proxy anonymity levels test](https://mosaicbrowser.com/blog/proxy-anonymity-levels-and-https) has the grading tables).

Mosaic is a desktop app

Email yourself the link and open it on your computer.

[How it works: A new IP for every profile](https://mosaicbrowser.com/features/proxy-providers)

## The echo service hides two of them

Which echo you use decides what you can see, and httpbin is the one most people reach for. Two things about its `/headers` endpoint matter here.

First, proxy headers are hidden unless you ask. httpbin keeps a list of headers that belong to the environment rather than the client (`Via`, `X-Forwarded-For`, `X-Forwarded-Proto`, `X-Real-Ip` and others) and drops them from the echo unless the URL ends in `?show_env=1`. Send it a request carrying `Via: 1.1 testproxy` and the plain URL returns no `Via`. Add `?show_env=1` and it comes back, along with an `X-Forwarded-For` that httpbin's own load balancer wrote, carrying your address. With `show_env` on, `X-Forwarded-For` is always present, so its presence means nothing and the address count means everything.

Second, the keys come back sorted. The response is a JSON object, and `Alpha` comes back before `Host` before `Zeta`, whatever order they were sent in. httpbin tells you which headers arrived and what they said, never their order.

Our own row has the same blind spot. Loading the plain URL, as it does, means it can catch `Forwarded` and will never catch `Via` or `X-Forwarded-For`, and httpbin does not echo a `Proxy-Connection` header either, so that one never shows up at all. If you use httpbin for this test, add `?show_env=1` and count the addresses in `X-Forwarded-For`: one is httpbin's load balancer, two means somebody else wrote one first.

## How to check request header order in Chrome yourself

For order you need your own echo, because the server has to print the headers as a list rather than a dictionary. Node keeps them that way in `req.rawHeaders`, alternating names and values, with the capitalisation the client used:

```
require('http').createServer((req, res) => {
  const lines = []
  for (let i = 0; i < req.rawHeaders.length; i += 2)
    lines.push(req.rawHeaders[i] + ': ' + req.rawHeaders[i + 1])
  res.end(lines.join('\n') + '\n')
}).listen(8898)

```

Run it with `node echo.js`, open `http://localhost:8898`, and Chrome's request appears line by line, `Host` first and `Connection` second, in the fixed order its network stack writes. Plain localhost is HTTP/1.1, with no TLS and so no HTTP/2. Real sites mostly get HTTP/2 over TLS, where names are lowercase inside a binary HEADERS frame, and an echo there has to print the frame's order. Chrome's order, and why a site treats it as a fingerprint, is in [header order is a fingerprint](https://mosaicbrowser.com/blog/chrome-header-order-through-a-proxy).

DevTools' Network panel shows Chrome's side and stops at your network card. For the proxy's side, put the same six lines on a VPS on plain `http://` and load it twice, direct and then through the proxy. Diff the two outputs. Anything new in the second was written by the proxy.

## What a Mosaic profile sends through its proxy

A Mosaic profile with an authenticated or SOCKS proxy goes through Mosaic, which logs in to the proxy for Chrome on your computer. On HTTPS Mosaic only passes the encrypted connection on and cannot change a byte of the request. On plain HTTP it does read the request, so we compared. A real Chrome driven through Mosaic at `httpbin.org/headers`, against the same request sent straight at the upstream proxy, came back with every header identical. The one difference was `X-Amzn-Trace-Id`, which Amazon's load balancer gives every request and which differs between any two of them.

The gateway's side of that conversation was a different story. It saw CONNECTs with no `User-Agent` and plain-HTTP requests carrying `Connection: close`, and [the proxy login that looked like a script](https://mosaicbrowser.com/blog/the-relay-that-looked-like-a-script) has the before and after.

What Mosaic cannot do is stop a proxy from adding headers of its own on plain HTTP. That belongs to the seller, which is why Header echo sits in the Leaks group of Detection tests, beside the IP and DNS pages, and why it is worth running against a new IP before anything you care about goes through it ([how to check a proxy before you use it](https://mosaicbrowser.com/guides/how-to-check-a-proxy-before-you-use-it) has the rest of that list).

## Questions

### How can I see the order of the headers Chrome sends?

Run a tiny Node server that loops over req.rawHeaders and prints each pair, then open it in Chrome. rawHeaders is a flat array in arrival order with the client's own capitalisation, which is all an HTTP/1.1 order check needs.

### Can JavaScript on a page read the request headers?

Only the ones the script put on the Request itself. Sec-CH-UA, Accept-Encoding and the cookie line are added by Chrome later, and a proxy's Via is added on another machine, so a page sees them only if some server prints them back.

### Why does httpbin not show Via or X-Forwarded-For?

httpbin treats them as environment headers and drops them from /headers by default. Add ?show_env=1 and they appear, along with an X-Forwarded-For that httpbin's own load balancer wrote with your address in it.

### Does httpbin show headers in the order they were sent?

No. The body is a JSON object with sorted keys, so Accept always comes before User-Agent. You learn names and values from it and nothing about order.

### Can a proxy add headers to an HTTPS request?

An ordinary one cannot: it forwards a CONNECT connection full of TLS it has no key for. A proxy that decrypts traffic, which needs its certificate installed on your machine, can rewrite anything.

## Related

[Header order is a fingerprint, and HTTPS keeps it intact](https://mosaicbrowser.com/blog/chrome-header-order-through-a-proxy): Sites read the order of Chrome's HTTP headers as well as their values. Over HTTPS a proxy only passes encrypted bytes on, so it cannot reorder a thing.

[Elite, anonymous, transparent: proxy levels mean little on HTTPS](https://mosaicbrowser.com/blog/proxy-anonymity-levels-and-https): Elite vs anonymous proxy is about X-Forwarded-For and Via on plain HTTP. Through a CONNECT connection to an HTTPS site, a proxy cannot add a header at all.

[Mosaic told the proxy gateway it was a script](https://mosaicbrowser.com/blog/the-relay-that-looked-like-a-script): Chrome sends Proxy-Connection: keep-alive, lower case, to every proxy. Mosaic sent Keep-Alive, no User-Agent and Connection: close, until we copied Chrome.

[How to check a proxy before you use it](https://mosaicbrowser.com/guides/how-to-check-a-proxy-before-you-use-it): Check that a proxy answers and connects, where its IP really is, whether the address is residential or blocklisted, and that the browser stays behind it.

[49 browser fingerprint detectors, and how we read them](https://mosaicbrowser.com/blog/forty-nine-detectors): Our browser fingerprint detectors list: 49 public test pages in five groups, 40 read by a script and 9 kept as reference because they print no verdict.



[Inspecting your traffic changes the TLS handshake a site sees](https://mosaicbrowser.com/blog/an-inspector-changes-the-handshake): Yes. mitmproxy and Proxyman open TLS to show you plaintext, so the site gets the inspector's ClientHello, not Chrome's. Inspect to debug, then turn it off.

[Proxy error 464 was our own extension talking to loopback](https://mosaicbrowser.com/blog/proxy-error-464): A 464 through a proxy is the gateway refusing your destination, not the site failing. Ours was a residential gateway that will not proxy to 127.0.0.1.

[A CONNECT to a raw IP means your machine resolved the name](https://mosaicbrowser.com/blog/a-numeric-connect-means-dns-leaked): To check if DNS goes through your proxy, read what the proxy is asked for. CONNECT example.com:443 means it resolved the name; a raw IP means you did.

## Mosaic, on your own computer

The browser this blog is about: its own Chromium, fingerprints from real machines and a proxy IP per profile. Free covers 3 profiles with no card, and Pro is $25 a month for any number of them.

Mosaic is a desktop app

Email yourself the link and open it on your computer.
