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

Cookie headers are received but not shown in devtools when using 'http' #1852

Closed
yoshuawuyts opened this issue Jun 3, 2015 · 6 comments
Closed

Comments

@yoshuawuyts
Copy link
Contributor

@zcbenz do you know if electron blocks the Set-Cookie header by default? Responses that carry this in the browser don't seem to have it in electron.

I read through the source, couldn't find any code that would point to that, but checking just in case this is true. Possibly related / of use to #1606.

@yoshuawuyts
Copy link
Contributor Author

I've created a repro for this: https://github.com/yoshuawuyts/electron-cookie-issues-repro.

It appears electron is indeed blocking cookie related headers.

update: 05/06/2014: It appears the only bug in electron is that cookie related headers aren't shown when fetching data.

electron blocks cookie headers

Using OSX@10.10.2 and electron@0.27.2 pulled in through electron-prebuilt.

Steps to reproduce (repro)

  • setup electron to load an index.html that loads client.js
  • perform an XHR request from client.js to a server.js that sets the Set-Cookie header

Actual results

  • no cookie headers are received cookie headers are not shown in devtools

Expected results

  • cookie headers are received cookie headers are shown in devtools
  • cookies are not stored (electron-cookies provides a workaround)

Screenshots

electron

screen shot 2015-06-04 at 11 37 40

chrome

screen shot 2015-06-04 at 11 53 13

@yoshuawuyts yoshuawuyts changed the title Is the Set-Cookie header blocked by default? Cookie headers are blocked Jun 4, 2015
@hokein
Copy link
Contributor

hokein commented Jun 4, 2015

Thanks for the detailed information. I can say that the Set-Cookie header is actually worked. You can view Cookies in Resources panel of dev-tool, then you will find the cookies.

I have no much idea about why dev-tools doesn't show the cookies header here, it might be a bug of dev-tools.

@yoshuawuyts
Copy link
Contributor Author

@hokein I'm not seeing any cookies in there, both with electron-cookies enabled and disabled.

screen shot 2015-06-04 at 15 14 45

edit: also tried the --enable-file-cookies flag, but it doesn't change anything.

@hokein
Copy link
Contributor

hokein commented Jun 5, 2015

Looks like you are loading the local file, are you sure you have sent the correct header?

In your reproduced repo, it actually works, see:

image

@yoshuawuyts
Copy link
Contributor Author

You were right, it was a header issue. Incidentally window.fetch doesn't support cookies so I had went with the nets module instead. The cookie headers not showing up in the request window is still a bug though, so I'll be updating the issue to only reflect that. Thanks for coming back to me so fast & helping me resolve my issues. 🎉

edit: I've also updated the repro with the solution in the README so any future adventurers that stumble into it know what to do.

@yoshuawuyts yoshuawuyts changed the title Cookie headers are blocked Cookie headers are received but not shown in devtools Jun 5, 2015
@yoshuawuyts
Copy link
Contributor Author

Update: due to #1574 nets uses request under the hood rather than xhr. When using xhr (e.g. XMLHTTPRequest) everything related to cookies is blocked and cannot be set. In the repro just require xhr instead to see the requests suddenly be oblivious of cookies.

const nets = require('xhr')

As a remark on the side: I wouldn't have expected that doing XHR requests with cookie authentication would have so many gotchas. I wish the electron client would try to stick as closely to a browser environment as possible, maybe even more than it already does. That way both knowledge and code are made more portable which is beneficial to all. Thanks!

@yoshuawuyts yoshuawuyts changed the title Cookie headers are received but not shown in devtools Cookie headers are received but not shown in devtools when using 'http' Jun 10, 2015
zcbenz added a commit that referenced this issue Jul 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants