playframework / play-ws

Standalone Play WS, an async HTTP client with fluent API
https://www.playframework.com/documentation/latest/JavaWS
Apache License 2.0
222 stars 87 forks source link

Streamed response headers are case sensitive #908

Closed GithubUser8080 closed 2 weeks ago

GithubUser8080 commented 3 weeks ago

When the request has .streamed(), then all methods to get headers, like response.getContentType() fail if the case is not an exact match. E.g for response Content-Type : application/json, response.getContentType() returns octet-stream. It only succeeds if the headers are all lowercase. Normally header matching must be case insensitive.

mkurz commented 2 weeks ago

@GithubUser8080 Just taking a quick look, maybe this line could be related? https://github.com/playframework/play-ws/blob/1f4f1d10aac594c6476fd53b550503a98c473a18/play-ws-standalone/src/main/scala/play/api/libs/ws/StandaloneWSResponse.scala#L73

GithubUser8080 commented 2 weeks ago

@GithubUser8080 Just taking a quick look, maybe this line could be related?

https://github.com/playframework/play-ws/blob/1f4f1d10aac594c6476fd53b550503a98c473a18/play-ws-standalone/src/main/scala/play/api/libs/ws/StandaloneWSResponse.scala#L73

I will try to remember the exact line, but if i remember correctly, all other response types, when getting headers, return a TreeMap copy of headers with case insensitive keys. Whereas StreamedResponse getHeaders() returns the original case sensitive map of headers from the underlying response.

GithubUser8080 commented 2 weeks ago

Normal response

https://github.com/playframework/play-ws/blob/1f4f1d10aac594c6476fd53b550503a98c473a18/play-ahc-ws-standalone/src/main/java/play/libs/ws/ahc/StandaloneAhcWSResponse.java#L64

Streamed response

https://github.com/playframework/play-ws/blob/1f4f1d10aac594c6476fd53b550503a98c473a18/play-ahc-ws-standalone/src/main/java/play/libs/ws/ahc/StreamedResponse.java#L66

mkurz commented 2 weeks ago
GithubUser8080 commented 2 weeks ago

Thanks

mkurz commented 2 weeks ago

@GithubUser8080 fix released:

mkurz commented 2 weeks ago

Please let me now if that works for you now, thanks!

GithubUser8080 commented 2 weeks ago

Please let me now if that works for you now, thanks!

It does, thank you for the fast response!