StandaloneAhcWSRequest.createProxy should setUsePreemptiveAuth(true) for basic auth
halfhp opened this issue · 0 comments
Play WS Version
1.1.10
API (Scala / Java / Neither / Both)
Scala
Expected Behavior
Requests that specify a Proxy with basic auth should setUsePreemptiveAuth(true) for the proxy realm.
Actual Behavior
Requests that specify a Proxy with basic auth never setUsePreemptiveAuth(true) for the proxy realm, causing the connection to fail.
Details / Steps to Reproduce
While unsuccessfully attempting to connect to a commercial proxy using basic auth I noticed that StandaloneAhcWSRequest
is inconsistent in it's application of realm configuration; for non-proxy requests usePreemptiveAuth
is always set to true for non DIGEST schemes, however, when making a proxy request, this logic is omitted.
Upon duplicating the scheme check logic in StandaloneAhcWSRequest.createProxy() my basic auth proxy requests began working.
This is the code I've been using to test:
val proxy = DefaultWSProxyServer(
host = "some.proxy.xx",
port = 222,
principal = Some("username"),
password = Some("password"))
wsClient
.url("http://api.ipify.org")
.withProxyServer(proxy)
.get().map( _.body[String])
If someone with more knowledge about how this code should be working can validate my findings, I'd be happy to issue a PR with a fix :-)