Closed torkus closed 3 years ago
It appears that there's an option in the underlying Apache HTTPClient 4.5.x that normalizes the URIs. See https://github.com/apache/httpcomponents-client/blob/4.5.x/httpclient/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java#L162-L164
A quick test shows this behavior:
user=> (org.apache.http.client.utils.URIUtils/normalizeSyntax (java.net.URI. "https://media.forgecdn.net/files/3135/377/MobInfo2-8.3.15%2BClassic.zip"))
#object[java.net.URI 0x43631a38 "https://media.forgecdn.net/files/3135/377/MobInfo2-8.3.15+Classic.zip"]
I think you should be able to get around this by passing in a custom http-request-config
with the specific option disabled. See https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/config/RequestConfig.Builder.html#setNormalizeUri(boolean)
Did a bit of a copy+paste of the RequestConfig
builder function in clj-http/core
with setNormalizeUri
to ~true
~ false
and it appears to works fine.
I've opened a PR.
Oh, and thank you for your reply, it was very helpful.
Any idea when/if my change will make it into clj-http?
@torkus sorry for the delay, 3.12.0 is out now 🎉
all good, thank you for your help, I appreciate it.
um ... this is embarrassing, but I think I made a simple logic mistake.
I had:
(.setNormalizeUri (or normalize-uri true))
and
(or false true) => true
I'll open a fix and include a test this time.
Fixed version here: https://github.com/dakrone/clj-http/pull/584
(no rush ;)
I have this (roughly):
with this output:
and from the above we can see that this:
is redirected to:
which exists, but instead this is requested:
which does not exist, resulting in a 404.
Is this a bug somewhere?
Using
clj-http 3.11.0
,java 11
,clojure 1.10.1