[crx] setting Request Headers

116 views
Skip to first unread message

elf Pavlik

unread,
Apr 21, 2010, 3:31:51 AM4/21/10
to Chromium-extensions
Hello =)

I would like to write a simple extension which will make possible for
the person using a browser to set/unset a 'From' request header.
I think I will figure out how to do the Browser Action, button, popup
part from available resources but I have no idea what API do I use to
set request headers...

I would like to make this extension for http://open-profile.info
project (currently in very early incubation).

Any help appreciated!

Thank you =)

--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.

Arne Roomann-Kurrik

unread,
Apr 28, 2010, 2:28:04 PM4/28/10
to elf Pavlik, Chromium-extensions
Hi,

  Currently extensions don't support modifying HTTP requests.  There have been a few requests for this feature, though - please star http://crbug.com/37280 in order to get notified about any changes.

~Arne

elf Pavlik

unread,
Apr 29, 2010, 2:58:37 AM4/29/10
to Arne Roomann-Kurrik, Chromium-extensions
On Wed, 28 Apr 2010 11:28:04 -0700, Arne Roomann-Kurrik
<kur...@google.com>
wrote:
> Hi,
>
> Currently extensions don't support modifying HTTP requests. There
have
> been a few requests for this feature, though - please star
> http://crbug.com/37280 in order to get notified about any changes.
>
> ~Arne

Hi, Arne!

Thanks for clarifying the situation and pointing me to the related issue!
Hopefully chromium will have this feature soon =)

Cheers,
elf Pavlik

elf Pavlik

unread,
Dec 14, 2011, 9:15:21 AM12/14/11
to Chromium-extensions
Excerpts from Arne Roomann-Kurrik's message of 2010-04-28 18:28:04 +0000:

> Hi,
>
> Currently extensions don't support modifying HTTP requests. There have
> been a few requests for this feature, though - please star
> http://crbug.com/37280 in order to get notified about any changes.
>
> ~Arne

Hello,

Any progress on this one? I see related issue here:
https://code.google.com/p/chromium/issues/detail?id=60101

Thanks!
=)

~ elf Pavlik ~

--
(living strictly moneyless already for over 2 years)
http://wwelves.org/perpetual-tripper
http://moneyless.info
http://hackers4peace.net

Dominic Battre

unread,
Dec 14, 2011, 10:04:51 AM12/14/11
to elf Pavlik, Chromium-extensions
Hi.

On Wed, Dec 14, 2011 at 3:15 PM, elf Pavlik <perpetua...@wwelves.org> wrote:
Excerpts from Arne Roomann-Kurrik's message of 2010-04-28 18:28:04 +0000:
> Hi,
>
>   Currently extensions don't support modifying HTTP requests.  There have
> been a few requests for this feature, though - please star
> http://crbug.com/37280 in order to get notified about any changes.
>
> ~Arne

Hello,

Any progress on this one? I see related issue here:
https://code.google.com/p/chromium/issues/detail?id=60101

This is basically done. You can modify headers with the web request API. http://code.google.com/chrome/extensions/trunk/webRequest.html

The API will appear as stable in the beta branch in a couple of days (i.e. you don't need to set the experimental flag in about://flags).
 
Best regards,
Dominic

Laurent Perez

unread,
Dec 17, 2011, 3:00:55 PM12/17/11
to Chromium-extensions
Hello

I've been trying to modify http headers with the webRequest API's
onBeforeSendHeaders method, using Chromium 18.0.975.0 (Build 114920).

When I pass the "requestHeaders" opt_extraInfoSpec, the returning
value of the function does not seem to be used, i.e when trying this :
var rh = [{name:'someheader',value:'foo'}];, return rh;, then the
headers sent are still the ones from requestHeaders. Modifying and
returning requestHeaders has no effect either.

If I set opt_extraInfoSpec to "blocking", then I can return my custom
rh headers array. However, I loose the original request headers
present in requestHeaders, obviously because opt_extraInfoSpec is not
"requestHeaders".

I understand the request needs to be blocked (I'm modifying headers),
but how can I find the original request headers since blocking
prevents passing them to the inner details object ?

Thanks,


On 14 déc, 16:04, Dominic Battre <bat...@chromium.org> wrote:
> Hi.
>
> On Wed, Dec 14, 2011 at 3:15 PM, elf Pavlik

> <perpetual-trip...@wwelves.org>wrote:


>
> > Excerpts from Arne Roomann-Kurrik's message of 2010-04-28 18:28:04 +0000:
> > > Hi,
>
> > >   Currently extensions don't support modifying HTTP requests.  There have
> > > been a few requests for this feature, though - please star

> > >http://crbug.com/37280in order to get notified about any changes.


>
> > > ~Arne
>
> > Hello,
>
> > Any progress on this one? I see related issue here:
> >https://code.google.com/p/chromium/issues/detail?id=60101
>

> This is basically done. You can modify headers with the web request API.http://code.google.com/chrome/extensions/trunk/webRequest.html

Peter Hultqvist

unread,
Dec 19, 2011, 5:42:18 PM12/19/11
to Laurent Perez, Chromium-extensions
On 17/12/11 21:00, Laurent Perez wrote:
> Hello
>
> I've been trying to modify http headers with the webRequest API's
> onBeforeSendHeaders method, using Chromium 18.0.975.0 (Build 114920).
>
> When I pass the "requestHeaders" opt_extraInfoSpec, the returning
> value of the function does not seem to be used, i.e when trying this :
> var rh = [{name:'someheader',value:'foo'}];, return rh;, then the
> headers sent are still the ones from requestHeaders. Modifying and
> returning requestHeaders has no effect either.
>
> If I set opt_extraInfoSpec to "blocking", then I can return my custom
> rh headers array. However, I loose the original request headers
> present in requestHeaders, obviously because opt_extraInfoSpec is not
> "requestHeaders".
>
> I understand the request needs to be blocked (I'm modifying headers),
> but how can I find the original request headers since blocking
> prevents passing them to the inner details object ?
>
> Thanks,
>
You should do:
return {requestHeaders: rh};

Also you can set multiple options in opt_extraInfoSpec such as:
chrome.webRequest.onBeforeSendHeaders.addListener(onBeforeSendHeaders,
{urls: ["<all_urls>"]}, ["requestHeaders", "blocking"]);

Dominic Battre

unread,
Dec 20, 2011, 1:55:36 AM12/20/11
to Peter Hultqvist, Laurent Perez, Chromium-extensions
Hi Laurent,

here is your checklist:

- did you request webRequest and webRequestBlocking permission in your manifest file?
- did you request host permissions in your manifest file? ("*:*.google.com", "<all_urls>", ... something like that)
- did you put the right filter statement in the the addListener event ({urls: ["<all_urls>"]})
- did you register the listener as blocking ("blocking" in opt_extraInfoSpec)

If you do all that, you should modify the requestHeaders from the details object that is passed to your callback and return it as shown in the documentation.

Best regards,
Dominic

--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.




--
Dominic Battré | Software Engineer | bat...@google.com | +49 (0) 89 - 83 930 9152

Laurent Perez

unread,
Dec 20, 2011, 6:57:26 AM12/20/11
to Chromium-extensions
Hi

I didn't understand opt_extraInfoSpec could take multiple options, everything is working fine now ;)

Thanks,

lauren
--
http://laurentperez.fr
J2EE tips and best practices


Reply all
Reply to author
Forward
0 new messages