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

Allow extraHeaders to be set for browser clients in XHR requests #519

Merged
merged 2 commits into from
Dec 30, 2016

Conversation

darrachequesne
Copy link
Member

To be used as (after #518 is merged):

io({ 
  transportOptions: {
    polling: {
      extraHeaders: { 'X-Requested-With': 'XMLHttpRequest' }
    },
  }
});

Closes #410

@lu4
Copy link
Contributor

lu4 commented Jan 30, 2017

@darrachequesne The feature doesn't seem to be working (according to examples from Readme.md)... The extraHeaders are omitted...

Browser code:

let engine = engineio({
    transportOptions: {
        polling: {
            extraHeaders: {
                'X-TEST': 'ZZZ'
            }
        }
    }
});

engine.on('open', () => {
    console.log(['open', engine]);

    engine.send('another test');

    engine.on('message', (data) => {
        console.log(['message', data]);
    });

    engine.on('close', () => {
        console.log(['close', engine]);
    });
});

Server code:

let engineServer = engine.attach(httpsServer);

engineServer.on('connection', function (socket: any) {
    debugger; // socket.request.headers does not contain X-TEST header
    console.log(['connection', socket]);

    socket.send('test');

    socket.on('message', function(data: any) {
        console.log(['message', data, socket]);
    });

    socket.on('close', function() {
        console.log(['close', socket]);
    });
});

The problem seems to be little bit further along the road, to be specific with

xhr.setDisableHeaderCheck(true);

in xhr.setDisableHeaderCheck(true); xhr doesn't contain setDisableHeaderCheck, so what's the reason to accept extraHeaders if they will be cancelled later?

@mikermcneil
Copy link

also related to #554

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