Closed Bug 1696037 Opened 4 years ago Closed 4 years ago

Expose X-Firefox-Http3 header in release builds

Categories

(Core :: Networking: HTTP, defect, P2)

defect

Tracking

()

RESOLVED FIXED
88 Branch
Tracking Status
firefox88 --- fixed

People

(Reporter: brandon, Assigned: kershaw)

Details

(Whiteboard: [necko-triaged])

Attachments

(2 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4426.0 Safari/537.36 Edg/90.0.814.0

Steps to reproduce:

Extension authors would like to be able to determine whether a page was loaded over HTTP/3. Extensions can do this for HTTP/2 by checking for the presence of the synthetic X-Firefox-Spdy header which Firefox adds to responses when the page is loaded over HTTP/2.

Currently the Network Inspector shows a column indicating whether a page was loaded over HTTP/3, but this is not exposed in a way that extensions can access. A patch1 was landed that exposes this value via a new synthetic header, "X-Firefox-Http3", however the code that adds that header is only present in debug builds.

Actual results:

Currently extensions have no way to programmatically determine if a page was loaded over HTTP/3. Extensions can determine when website advertises HTTP/3 support via the Alt-Svc header but its presence can not be a guarantee that request did load via HTTP/3.

Expected results:

Extensions should be able to inspect the synthetic X-Firefox-Http3 header in the response to determine if a page was loaded over HTTP/3.

The Bugbug bot thinks this bug should belong to the 'Core::Networking: HTTP' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → Networking: HTTP
Product: Firefox → Core

(In reply to brandon from comment #0)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_2_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4426.0 Safari/537.36 Edg/90.0.814.0

Steps to reproduce:

Extension authors would like to be able to determine whether a page was loaded over HTTP/3. Extensions can do this for HTTP/2 by checking for the presence of the synthetic X-Firefox-Spdy header which Firefox adds to responses when the page is loaded over HTTP/2.

Currently the Network Inspector shows a column indicating whether a page was loaded over HTTP/3, but this is not exposed in a way that extensions can access. A patch[1] was landed that exposes this value via a new synthetic header, "X-Firefox-Http3", however the code that adds that header is only present in debug builds.

No, the code here means we only check the result of responseHead->SetHeader in debug build. Actually, this code does add X-Firefox-Http3 in release build.

Wouldn't that mean that I should be seeing this in the network tab > response headers when the page is loaded using HTTP3?

Testing on https://quic.tech:8443 yields the following results:

http2:

HTTP/2 200 OK
server: nginx
date: Fri, 05 Mar 2021 15:21:23 GMT
content-type: text/html
last-modified: Mon, 18 May 2020 21:16:53 GMT
etag: W/"5ec2fb45-1ce"
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-content-type-options: nosniff
x-frame-options: DENY
x-xss-protection: 1; mode=block
referrer-policy: no-referrer
alt-svc: h3-29=":8443"; ma=86400, h3-28=":8443"; ma=86400, h3-27=":8443"; ma=86400
content-encoding: gzip
X-Firefox-Spdy: h2

http3:

HTTP/3 200 OK
server: quiche
content-length: 462

My test results are from Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:86.0) Gecko/20100101 Firefox/86.0 release build.

hmm, I can see that this line is called, but X-Firefox-Http3 is not presented in the response header.

ni myself to take a look.

Flags: needinfo?(kershaw)
Assignee: nobody → kershaw
Severity: -- → S4
Type: enhancement → defect
Flags: needinfo?(kershaw)
Priority: -- → P2
Whiteboard: [necko-triaged]

Note that with the patch in comment #6, X-Firefox-Http3 is still not displayed in network tab of devtool.
The reason is that devtool is using visitOriginalResponseHeaders to get all headers and visitOriginalResponseHeaders only contains the real headers sent by servers. Since X-Firefox-Http3 is added internally by firefox, this header is not in original response headers. However, it's exposed to web extensions. In my local test, I can see X-Firefox-Http3 with other web extensions.

Thanks for adding this.

Why does this work for X-Firefox-Spdy though?
As far as I can tell this isn't sent by the server either.

(In reply to Richard Schwab from comment #8)

Created attachment 9207768 [details]
response-headers-http2.png

Thanks for adding this.

Why does this work for X-Firefox-Spdy though?
As far as I can tell this isn't sent by the server either.

Yes, I know. The place where we add X-Firefox-Spdy makes the higher layer think this is also a header from the server. I think this is a bug in our h2 code.

Thanks for the explanation.

Pushed by kjang@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ff312d479d33 Make sure X-Firefox-Http3 is set properly r=necko-reviewers,valentin
Status: UNCONFIRMED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 88 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: