[Android] Image loading request is performed without cookie which was set earlier by "SetCookie" header of response
See original GitHub issueDescription
- I have a server which returns image only if request has authorization cookie.
- I authorise on this server and get a HTTP response with
Set-Cookie
header with cookies in content. - 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:
- 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
- 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
- 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
- React Native version: 0.43.4
- Platform: Android 7.1
- Development Operating System: macOS Seems similar to https://github.com/facebook/react-native/issues/6316 but on Android.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:15 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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 😞
Does not work in 0.56.0 as well.