Closed Bug 1900362 Opened 1 month ago Closed 3 days ago

Do not override the Priority header when set by the user

Categories

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

enhancement
Points:
1

Tracking

()

RESOLVED FIXED
129 Branch
Tracking Status
firefox129 --- fixed

People

(Reporter: valentin, Assigned: sekim)

References

(Blocks 1 open bug)

Details

(Whiteboard: [necko-triaged][necko-priority-next])

Attachments

(1 file)

See conversation about chrome behaviour Define behavior for Priority request header · Issue 1718 · whatwgfetch

At least in the case of Chrome, if the Priority header is set before it gets to the networking stack then the user-supplied value will be used (like was discussed above).

I think the fix would be rather simple:
https://searchfox.org/mozilla-central/rev/dc08a7321a22918d5a26b7641f9b10cd2a09d98e/netwerk/protocol/http/nsHttpChannel.cpp#488-491

void nsHttpChannel::SetPriorityHeader() {
  nsAutoCString userSetPriority;
  Unused << GetRequestHeader("Priority"_ns, userSetPriority);
  if (!userSetPriority.IsEmpty()) {
     // insert comment here :)
     return;
  }

  uint8_t urgency =
      nsHttpHandler::UrgencyFromCoSFlags(mClassOfService.Flags(), mPriority);
  bool incremental = mClassOfService.Incremental();
Whiteboard: [necko-triaged] → [necko-triaged][necko-priority-next]

See also https://github.com/whatwg/fetch/issues/1718#issuecomment-2145347776

The Priority header implementation in Chrome and Firefox ignores the existence of the request filtering engine available to extensions. declarativeNetRequest and webRequest do not see the header because it is set by the browser after request filtering occurs, so extensions cannot remove the header, they will only be able to set a custom value.

We should also consider moving the call to SetPriorityHeader a bit earlier to allow webextensions to change/remove the value.

Assignee: nobody → sekim
Status: NEW → ASSIGNED
Attachment #9405893 - Attachment description: Bug 1900362 - Do not override the Priority header when set by the user r=valentin → WIP: Bug 1900362 - Do not override the Priority header when set by the user and move SetPriorityHeader call before onModifyRequest r=valentin
Attachment #9405893 - Attachment description: WIP: Bug 1900362 - Do not override the Priority header when set by the user and move SetPriorityHeader call before onModifyRequest r=valentin → Bug 1900362 - Do not override the Priority header when set by the user and move SetPriorityHeader call before onModifyRequest r=kershaw,#necko
Component: Networking → Networking: HTTP
Attachment #9405893 - Attachment description: Bug 1900362 - Do not override the Priority header when set by the user and move SetPriorityHeader call before onModifyRequest r=kershaw,#necko → WIP: Bug 1900362 - Do not override the Priority header when set by the user and move SetPriorityHeader call before onModifyRequest r=kershaw,#necko
Attachment #9405893 - Attachment description: WIP: Bug 1900362 - Do not override the Priority header when set by the user and move SetPriorityHeader call before onModifyRequest r=kershaw,#necko → Bug 1900362 - Do not override the Priority header when set by the user and move SetPriorityHeader call before onModifyRequest r=kershaw,#necko
Pushed by kjang@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/6a92033df002
Do not override the Priority header when set by the user and move SetPriorityHeader call before onModifyRequest r=necko-reviewers,kershaw,devtools-reviewers,bomsy
Flags: needinfo?(sekim)
Attachment #9405893 - Attachment description: Bug 1900362 - Do not override the Priority header when set by the user and move SetPriorityHeader call before onModifyRequest r=kershaw,#necko → Bug 1900362 - Do not override the Priority header when set by the user r=kershaw,#necko
Pushed by kjang@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/2f58630eb7af
Do not override the Priority header when set by the user r=necko-reviewers,kershaw,devtools-reviewers,bomsy,webdriver-reviewers,whimboo
Status: ASSIGNED → RESOLVED
Closed: 3 days ago
Resolution: --- → FIXED
Target Milestone: --- → 129 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: