Closed Bug 1402570 Opened 7 years ago Closed 6 years ago

Duplicate HTTP headers handled inconsistently in webRequest API

Categories

(WebExtensions :: Request Handling, defect, P3)

57 Branch
defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1377689

People

(Reporter: MTest31, Unassigned)

References

Details

If you apply curl -I to the URL [1] you are getting response headers like:

Content-Type: application/json
Content-Type: text/foo; charset=UTF-8

If you type that URL into a new tab, the Content-Type gets recognized as text/foo because it shows you a window "what to do with the file: download it, open it with program X". If it were recognized as json, you'd get the json view. However, if you then download and have the network console open, you see only one entry for the Content-Type, which is "Content-Type: application/json". This is also the same information exposed to web extensions via the webRequest API. If you have extension code like:

function headerRecv(responseDetails) {
	console.log("Headers received in response ", responseDetails);
}
browser.webRequest.onHeadersReceived.addListener(
	headerRecv,
	{
		urls: ["<all_urls>"],
		types: ["main_frame"]
	},
	["blocking", "responseHeaders"]
);

You get a message that contains only the "Content-Type: application/json" header as well.

Now per RFC 7230 [2] those double response headers are invalid (Content-Type allows no comma separated lists). But that doesn't mean that Firefox should exhibit inconsistent behaviour. I guess the best thing here would be to deduplicate the header consistent with the MIME type recognition logic.

[1]: https://httpbin.org/response-headers?Server=httpbin&Content-Type=text%2Ffoo%3B+charset%3DUTF-8
[2]: https://tools.ietf.org/html/rfc7230#section-3.2.2
Blocks: 1344646
Flags: needinfo?(amckay)
I thought I could find a duplicate, but I can't.
Flags: needinfo?(amckay)
Priority: -- → P3
This may be the same issue as Bug 1377689
Confirmed that bug exists in 58, but not in the current stable (60). So I assume that this has been fixed by bug 1377689.
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → DUPLICATE
Product: Toolkit → WebExtensions
You need to log in before you can comment on or make changes to this bug.