question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android] Image loading request is performed without cookie which was set earlier by "SetCookie" header of response

See original GitHub issue

Description

  1. I have a server which returns image only if request has authorization cookie.
  2. I authorise on this server and get a HTTP response with Set-Cookie header with cookies in content.
  3. Then I show an Image with URL pointing to this server. Image is failed to load. Same thing works OK on iOS.

I checked the network traffic, and found this:

  1. Response which sets the cookie looks like this:
HTTP/1.1 200 OK
Server: nginx
Date: Sat, 22 Apr 2017 16:43:31 GMT
Content-Type: application/json;charset=utf-8
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Set-Cookie: JSESSIONID={Censored};Path=/somepath;Secure;HttpOnly
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Access-Control-Expose-Headers: Location
Cache-Control: no-cache, no-store, no-transform, must-revalidate
Vary: Accept-Encoding, User-Agent
Content-Encoding: gzip
Strict-Transport-Security: max-age=31536000; includeSubdomains;
X-Content-Type-Options: nosniff
Transfer-Encoding: chunked
Connection: Keep-alive
  1. Regular fetch-drived network requests after this are performed with this cookie:
GET {Censored/some url} HTTP/1.1
content-type: application/json
accept: application/json, text/plain, */*
authorization: {Censored}
Host: {Censored}
Connection: Keep-Alive
Accept-Encoding: gzip
Cookie: JSESSIONID={Censored/HERE IT IS!!}
User-Agent: okhttp/3.4.1
  1. Image requests are performed without this cookie:
GET {Censored}/_persistent/project-diff.png?file=96-37&c=false HTTP/1.1
Host: {Censored}
Connection: Keep-Alive
Accept-Encoding: gzip
User-Agent: okhttp/3.4.1

Solution

The code which loads image should respect that cookie set before.

Additional Information

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
andrey-sklcommented, Oct 9, 2017

Sadly that’s the way how react-native evolves: it doesn’t care about great bunch of small but breaking stuff issues there and there. Will it get some kind of polishing and bugfixing eventually? Nobody knows 😞

0reactions
ghostcommented, Aug 27, 2018

Does not work in 0.56.0 as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Set a cookie to a webView in Android - Stack Overflow
I'm getting a HttpResponse from a server when checking if a username or password is correct. When I load the url in a...
Read more >
Set-Cookie - HTTP - MDN Web Docs
The Set-Cookie HTTP response header is used to send a cookie from the server to the user agent, so that the user agent...
Read more >
CookieManager - Android Developers
CookieManager represents cookies as strings in the same format as the HTTP Cookie and Set-Cookie header fields (defined in RFC6265bis).
Read more >
7 Keys to the Mystery of a Missing Cookie - Medium
Solution tip: On your server code, set the appropriate response headers. Here is the example of how this could be done in Java...
Read more >
Set-Cookie - HTTP - UDN Web Docs: MDN Backup
The Set-Cookie HTTP response header is used to send a cookie from the server to the user agent, so the user agent can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found