How to override HTTP response code

8,960 views
Skip to first unread message

Hao Nguyen

unread,
Jul 29, 2022, 10:12:19 AM7/29/22
to Chromium Extensions
Hi,

I have a dev tool Chrome extension (ModResponse) that allows developers to override their HTTP response. Using the debugger API + Fetch domain, I am able to override the HTTP response body. However, it looks the Fetch API is no longer able to modify the responseCode and responseHeaders (Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1275920, but it seems to be neglected). Are there alternative APIs that we can use to modify the responseCode?

Thanks,
Hao

wOxxOm

unread,
Jul 30, 2022, 10:15:33 AM7/30/22
to Chromium Extensions, hao...@gmail.com

Hao Nguyen

unread,
Aug 3, 2022, 3:53:13 PM8/3/22
to Chromium Extensions, wOxxOm, Hao Nguyen
Tried the Network methods. They do not override status code or response headers either.

Note that the same codes work with both Fetch and Network methods when running on Edge v103. They do not work in Chrome v104 or Brave v104 (it used to work in Brave but not any more).

Simeon Vincent

unread,
Aug 5, 2022, 1:34:57 AM8/5/22
to Hao Nguyen, Chromium Extensions, wOxxOm
Hm, that does seem quite odd. I'll see if I can find someone on DevTools to take a look at it.

Simeon - @dotproto
Chrome Extensions DevRel


--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/d1e4588e-85c5-43bf-ae34-8e8a590589a0n%40chromium.org.

Hao Nguyen

unread,
Aug 9, 2022, 12:52:00 PM8/9/22
to Chromium Extensions, Simeon Vincent, Chromium Extensions, wOxxOm, Hao Nguyen
I just tried this on Chromium v106 and the APIs are working correctly as expected. It appears that the bug might be somewhere in Chrome and not in Chromium.

Simeon Vincent

unread,
Aug 9, 2022, 9:11:29 PM8/9/22
to Hao Nguyen, Chromium Extensions, wOxxOm
There's very little difference between Chrome and Chromium. If it works in Chromium 106, it should also work in Chrome Canary (currently on Version 106.0.5229.0). Hao, could you retest in Canary and follow up here with your observations?

Simeon - @dotproto
Chrome Extensions DevRel

Hao Nguyen

unread,
Aug 10, 2022, 8:22:01 AM8/10/22
to Chromium Extensions, Simeon Vincent, Chromium Extensions, wOxxOm, Hao Nguyen
Just did, and posted my observations at https://bugs.chromium.org/p/chromium/issues/detail?id=1275920
Reply all
Reply to author
Forward
0 new messages