change header referer on xhr

3,348 views
Skip to first unread message

Alexey Romanenko

unread,
Jan 26, 2011, 10:02:57 AM1/26/11
to Chromium-extensions
Hello all.

If I try to set referer on xhr I get error Refused to set unsafe
header "Referer"

var xhr = new XMLHttpRequest();
xhr.open("GET", "google.com", true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
console.log(xhr);
}
}
xhr.setRequestHeader('Referer', 'http://google.com');
xhr.send();

This code print 'Refused to set unsafe header "Referer"' on console.

How can I change referer for my request?

Arne Roomann-Kurrik

unread,
Jan 26, 2011, 12:36:07 PM1/26/11
to Alexey Romanenko, Chromium-extensions
This is explicitly disallowed by the XHR spec:

Eventually we'll probably have an API to modify HTTP requests issued by the browser, but I don't believe this is possible right now.

~Arne



--
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.


Alexey Romanenko

unread,
Jan 29, 2011, 1:38:26 AM1/29/11
to Chromium-extensions
Thanks for replay.

May be exist other path for do it?

On Jan 26, 11:36 pm, Arne Roomann-Kurrik <kur...@chromium.org> wrote:
> This is explicitly disallowed by the XHR spec:http://www.w3.org/TR/XMLHttpRequest/#dom-xmlhttprequest-setrequestheader
>
> Eventually we'll probably have an API to modify HTTP requests issued by the
> browser, but I don't believe this is possible right now.
>
> ~Arne
>
> On Wed, Jan 26, 2011 at 7:02 AM, Alexey Romanenko <slimu...@gmail.com>wrote:
>
>
>
>
>
>
>
> > Hello all.
>
> > If I try to set referer on xhr I get error Refused to set unsafe
> > header "Referer"
>
> > var xhr = new XMLHttpRequest();
> > xhr.open("GET", "google.com", true);
> > xhr.onreadystatechange = function() {
> >  if (xhr.readyState == 4) {
> >    console.log(xhr);
> >  }
> > }
> > xhr.setRequestHeader('Referer', 'http://google.com');
> > xhr.send();
>
> > This code print 'Refused to set unsafe header "Referer"' on console.
>
> > How can I change referer for my request?
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Chromium-extensions" group.
> > To post to this group, send email to chromium-extensi...@chromium.org.
> > To unsubscribe from this group, send email to
> > chromium-extensions+unsubscr...@chromium.org<chromium-extensions%2Bunsubscr...@chromium.org>
> > .

PhistucK

unread,
Jan 29, 2011, 3:45:44 AM1/29/11
to Alexey Romanenko, Chromium-extensions
Not through web platform APIs, you can only do it through NPAPI (c++, native code) currently.

PhistucK



To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.

Alexey Romanenko

unread,
Jan 29, 2011, 3:54:55 AM1/29/11
to Chromium-extensions
Okay, thanks. I will try to do it :)

On 29 янв, 14:45, PhistucK <phist...@gmail.com> wrote:
> Not through web platform APIs, you can only do it through NPAPI (c++, native
> code) currently.
>
> ☆*PhistucK*
> > <chromium-extensions%2Bunsubscr...@chromium.org<chromium-extensions%252Bunsubscr...@chromium.org>
Reply all
Reply to author
Forward
0 new messages