OpenUnirest / unirest-java

Unirest in Java: Simplified, lightweight HTTP client library.
Other
57 stars 7 forks source link

Invalid Headers when using Unirest #23

Closed ryber closed 6 years ago

ryber commented 6 years ago

per https://github.com/Kong/unirest-java/issues/97

Unirest.post("https://dweet.io/dweet").fields(map).asJson(); // map is a HashMap of course
I am making a standard POST request to a server and I get the following while receiving a response.

Jun 06, 2015 4:36:18 PM org.apache.http.client.protocol.ResponseProcessCookies processCookies WARNING: Invalid cookie header: "Set-Cookie: dweet:thing=hallowed-mailbox; path=/; expires=Sun, 05 Jun 2016 20:36:16 GMT; httponly". Invalid 'expires' attribute: Sun, 05 Jun 2016 20:36:16 GMT Can someone please help me fix this frustrating error? I love Unirest, it's like requests but in Java too!


I encountered the same problem and found a solution:

RequestConfig globalConfig = RequestConfig.custom() .setCookieSpec(CookieSpecs.IGNORE_COOKIES).build();          
HttpClient httpclient = HttpClients.custom().setDefaultRequestConfig(globalConfig).build(); Unirest.setHttpClient(httpclient);
ryber commented 6 years ago

todo: add option to ignore cookies as a one liner with the Options class

ryber commented 6 years ago

This is caused by the cookie being in an invalid format, and it doesn't stop things. only produces a warning. There might be a good reason to have a easy way to set custom cookie policies outside of setting a custom client but we will not support that at this time.