puppetlabs / clj-http-client

HTTP client library wrapping Apache HttpAsyncClient
Apache License 2.0
15 stars 30 forks source link

(maint) add support for multiple Set-Cookie headers in a response #104

Closed jonathannewman closed 8 months ago

jonathannewman commented 8 months ago

The design of the client does not allow multiple entries for the same header name, as headers are returned in a map, rather than an array of them. As a result, headers like "Set-Cookie" would only return the last one seen if they were encountered. This alters the behavior to concatenate any of the "Set-Cookie" entries together, separated by a newline character. This seems to be a fairly common convention for clients that use headers with maps.

Tests were updated to include multiple cookies, and demonstrate the behavior.

jonathannewman commented 8 months ago

The eastwood failure is related to a lein 2.11.1 and eastwood incompatibility. When run locally with an older version of lein, it all passes:

➜  clj-http-client git:(maint/main/multiple-headers) ✗ /usr/local/bin/lein-2-10-0 eastwood
== Eastwood 1.2.2 Clojure 1.11.1 JVM 17.0.8 ==
Directories scanned for source files: src/clj test
== Linting puppetlabs.http.client.common ==
== Linting puppetlabs.http.client.metrics ==
== Linting puppetlabs.http.client.async ==
== Linting puppetlabs.http.client.async-unbuffered-test ==
== Linting puppetlabs.http.client.sync ==
== Linting puppetlabs.http.client.metrics-test ==
== Linting puppetlabs.http.client.test-common ==
== Linting puppetlabs.http.client.gzip-request-test ==
== Linting com.puppetlabs.http.client.impl.java-client-test ==
== Linting puppetlabs.http.client.sync-plaintext-test ==
== Linting puppetlabs.http.client.sync-ssl-test ==
== Linting puppetlabs.http.client.async-plaintext-test ==
== Linting com.puppetlabs.http.client.impl.metrics-unit-test ==
== Linting done in 7718 ms ==
== Warnings: 0. Exceptions thrown: 0
➜  clj-http-client git:(maint/main/multiple-headers) ✗