Skip to content

Loading…

GM_xmlhttpRequest cannot set HTTP referer header #1240

Closed
u-nn opened this Issue · 2 comments

2 participants

@u-nn

Trying to set the "Referer" HTTP header in a GM_xmlhttpRequest causes the header to be silently ignored, and no referer is sent. I believe this is deliberately done in firefox, so if this is a bug at all, it's a firefox bug and not a gm bug. However, this can be worked around in gm by setting the referer from an http-on-modify-request observer instead of directly in the XHR request.

Commit u-nn/greasemonkey@c6a2897 shows an implementation of this workaround, which seems to work for me. I'm not sure how ugly or undesirable that approach is, but I would really like to be able to set referers (this is kinda required for automating form submissions cross-domain). If it's not desired without special consideration, this could also be enabled by setting some certain GM_XHR 'details' field to turn it on, instead of just always doing this when 'Referer' is encountered in the set headers.

Googling this issue brings up some discussion elsewhere, but I don't see an issue here, and I haven't seen anyone bring up the idea of using the observer workaround in GM yet.

@arantius
Collaborator

Confirmed, test case: https://gist.github.com/919968

Should expect its output to contain the referer header, today it does not.

@arantius arantius closed this in 2198702
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.