Closed Bug 1854389 Opened 1 year ago Closed 1 year ago

Cannot determine OHTTP proxy return status code if proxy rejects with 429 or similar

Categories

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

defect

Tracking

()

RESOLVED FIXED
120 Branch
Tracking Status
firefox120 --- fixed

People

(Reporter: Gijs, Assigned: valentin)

References

(Blocks 2 open bugs)

Details

(Whiteboard: [necko-triaged])

Attachments

(1 file)

OHTTP channels' response header and response status handling code returns NS_ERROR_NOT_AVAILABLE if there is no binary http response (ie no encapsulated response from the gateway that was handed over by the proxy).

This means that if the proxy returns nothing combined with a 4** or 5** error code, I think we hit: https://searchfox.org/mozilla-central/rev/077fc34d03b85b09add26b5f99f1a3a3a72c8720/netwerk/protocol/http/ObliviousHttpChannel.cpp#693-696

nsresult ObliviousHttpChannel::ProcessOnStopRequest() {
  if (mRawResponse.IsEmpty()) {
    return NS_OK;
  }

and never set mBinaryHttpResponse, consumers cannot determine the HTTP response code from the proxy. This is bad because it means we cannot do any differentiated error handling on the client side based on the proxy's response.

Valentin, per bug 1845519 comment 3, do you have concrete ideas on how to more clearly separate the outer/inner request status/response headers?

Flags: needinfo?(valentin.gosu)
Assignee: nobody → valentin.gosu
Status: NEW → ASSIGNED

Gijs, the patch I attached allows you to inspect the innerChannel (HTTP channel).
I imagine it would work something like this:

https://searchfox.org/mozilla-central/rev/699a7704521354cac1e6a0679029c89ca899e25c/toolkit/components/shopping/content/ShoppingProduct.mjs#549-551

let httpStatus = request.QueryInterface(
  Ci.nsIObliviousHttpChannel
).innerChannel.responseStatus;
if (httpStatus == 200) {
  ...
  let ohttpStatus = request.QueryInterface(
    Ci.nsIHttpChannel
  ).responseStatus;
}

Let me know if that works or if you prefer something else.

Flags: needinfo?(valentin.gosu)
Severity: -- → S3
Priority: -- → P1
Whiteboard: [necko-triaged]
Pushed by valentin.gosu@gmail.com: https://hg.mozilla.org/integration/autoland/rev/f520eb31f9f7 Allow inspecting the innerChannel of an ObliviousHttpChannel r=Gijs,necko-reviewers,jesup
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 120 Branch
Blocks: 1859768
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: