Can I Inject A Content-length Header Into Chrome?
I'm trying to make my first Chrome Extension and it has been quite a learning experience. I'm almost done, but this last piece is killing me. I know Google doesn't want you to use
Solution 1:
Ok, so I posted that at 3:00 AM. After getting some much needed sleep, I woke up this morning and talked to a friend about it. He pointed out that the mistake was actually in my ajax call. I fixed that and now I can send Content-Length from my extension. The above code does work.
A few notes for the code I posted above for anybody searching for this later:
- I'm using underscore to loop through the arrays
- This strips all other headers and only adds the headers starting with "rh-". You may or may not want that.
- You have to have ["requestHeaders", "blocking"] as your last argument in onBeforeSendHeaders.addListener()
- In your manifest.json permissions make sure you have "webRequest" and "webRequestBlocking"
Although not tested, this should work on other headers that Chrome says it won't pass. Here is a list of the headers Google says it doesn't provide in onBeforeSendHeaders (as documented here):
- Authorization
- Cache-Control
- Connection
- Content-Length
- Host
- If-Modified-Since
- If-None-Match
- If-Range
- Partial-Data
- Pragma
- Proxy-Authorization
- Proxy-Connection
- Transfer-Encoding
Hope this helps.
Post a Comment for "Can I Inject A Content-length Header Into Chrome?"