Closed Rakambda closed 1 year ago
headers cannot contain character outside of lower ASCII, so Chinese is not possible, its just not a valid header at all. The date MUST be expressed with just ASCII.
Yes, but when providing cookies to unirest, a date object is given, not a string. It is unirest itself that transforms the cookie into an invalid header due to the date formater being locale dependant.
If I understand correctly, your solution to fix this would be for me forget about using the cookies feature and manually add them as headers ; which isn't really that convinient.
Ah I see what you are saying, I'll get in a fix this weekend
This is complete in v3.13.13 / v4.0.0-RC5
Describe the bug I have a case where a user has his locale set into Chinese, and when I try to set a cookie with an expiry date, it fails verification (in JDK) because some characters are invalid (the Chinese ones).
Looking a bit how cookies are added I managed to get to
unirest-java-core-4.0.0-RC4-sources.jar!/kong/unirest/core/Cookie.java:146
where header is added withexpires.format(DateTimeFormatter.ofPattern("EEE, dd-MMM-yyyy HH:mm:ss zzz"))
whereEEE
andMMM
are locale dependant.I don't really know how the RFC 7230 works but shouldn't these values be forced to be in an English locale? (and therefor use something like
expires.format(DateTimeFormatter.ofPattern("EEE, dd-MMM-yyyy HH:mm:ss zzz", Locale.forLanguageTag("en")))
To Reproduce Steps to reproduce the behavior:
Expected behavior Cookie to be added properly to the headers of the request
Environmental Data: