Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support web-workers XMLHttpRequest #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hankhero
Copy link

@hankhero hankhero commented Nov 9, 2014

for a web-worker, window is unavailable butXMLHttpRequest is available on the global 'self' object

for a web-worker, window is unavailable butXMLHttpRequest is available on the global 'self' object
@canastro
Copy link

This would be really useful!

@@ -50,7 +50,10 @@ http.Agent = function () {};
http.Agent.defaultMaxSockets = 4;

var xhrHttp = (function () {
if (typeof window === 'undefined') {
if (typeof self !== 'undefined' && self.XMLHttpRequest) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this:

if (typeof XMLHttpRequest !== 'undefined') {
    return XMLHttpRequest;
}

And then remove the second check for window.XMLHttpRequest below.

@tschaub
Copy link
Contributor

tschaub commented Aug 19, 2015

Agreed this would be useful. For others looking to work around the window checking, you can add this hack to whatever module requires http:

self.window = self;

And with this, window.XMLHttpRequest will be defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants