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

Adding basic support for sending cookies into xhr handshakes #439

Closed
wants to merge 2 commits into from

Conversation

jscharlach
Copy link
Contributor

No description provided.

@ajaymaru
Copy link

+1

2 similar comments
@jkingyens
Copy link

+1

@rituparnawy
Copy link

+1

@danielkcz
Copy link
Contributor

👍
I am wondering why this hasn't been merged yet. It's so simple and elegant solution...

@danielkcz
Copy link
Contributor

Actually this doesn't solve a thing. See my latest comment in #344.

@chill117
Copy link

I have been struggling to get unit tests involving socket.io-client to work with authentication. This pull request plus a minor change to the xmlhttprequest module that the socket.io-client module depends on worked for me. Here are the instructions for the additional changes:

Change the following of socket.io-client/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:

  // These headers are not user setable.
  // The following are allowed but banned in the spec:
  // * user-agent
  var forbiddenRequestHeaders = [
    "accept-charset",
    "accept-encoding",
    "access-control-request-headers",
    "access-control-request-method",
    "connection",
    "content-length",
    "content-transfer-encoding",
    "cookie",
    "cookie2",
    "date",
    "expect",
    "host",
    "keep-alive",
    "origin",
    "referer",
    "te",
    "trailer",
    "transfer-encoding",
    "upgrade",
    "via"
  ];

To:

  // These headers are not user setable.
  // The following are allowed but banned in the spec:
  // * user-agent
  var forbiddenRequestHeaders = [
    "accept-charset",
    "accept-encoding",
    "access-control-request-headers",
    "access-control-request-method",
    "connection",
    "content-length",
    "content-transfer-encoding",
    //"cookie",
    "cookie2",
    "date",
    "expect",
    "host",
    "keep-alive",
    "origin",
    "referer",
    "te",
    "trailer",
    "transfer-encoding",
    "upgrade",
    "via"
  ];

And, add the following immediately after the above code:

  // Forbid "Cookie" header in all environments EXCEPT 'test'
  if (process.env.NODE_ENV != 'test')
    forbiddenRequestHeaders.push('cookie')

This pull request was closed.
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.

6 participants