-
Notifications
You must be signed in to change notification settings - Fork 83
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
Support multiple values for HTTP header with same key #411
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also modify HttpHeaders.getAll()
to split the values by ,
here:
kotlin-toolkit/readium/shared/src/main/java/org/readium/r2/shared/util/http/HttpHeaders.kt
Line 46 in 1570e80
value |
As the caller is using getAll()
instead of get()
, we can infer that the header supports multiple values and so should be split by ,
to expand all the values into a single List<String>
.
readium/shared/src/main/java/org/readium/r2/shared/util/http/DefaultHttpClient.kt
Outdated
Show resolved
Hide resolved
df2ecd4
to
9132df0
Compare
That's right. The |
Actually, public methods are |
That's what I had in mind. But we could also have Unfortunately we can't preemptively split the values as some single-value headers are allowed to contain a comma, e.g. Expires: Wed, 21 Oct 2015 07:28:00 GMT |
Unfortunately, even single-value headers can have multiple occurrences. For instance, I'm afraid that none of both methods would be suitable for reading headers such as OkHttp's strategy seems the wisest choice to me. |
You're right, HTTP headers are a mess! Which strategy OkHttp uses? |
Actually they still offer a helper to get the raw value of the last header with a given name. In our case, that would mean offering |
Sounds good. With |
Yes! I updated the interface. |
Deprecated
Shared
DefaultHttClient.additionalHeaders
is deprecated. Set all the headers when creating a newHttpRequest
, or modify outgoing requests inDefaultHttpClient.Callback.onStartRequest()
.