Open mirelon opened 9 years ago
You cannot use InternalDefaults of Dispatch. Instead use e.g.
lazy val asyncHttpClient: AsyncHttpClient = new AsyncHttpClient(
new NettyAsyncHttpProvider(new AsyncHttpClientConfig.Builder().setUseProxyProperties(true).build()));
lazy val http = new Http(asyncHttpClient)
Should I make a pull request?
I don't know which files should be modified in here: https://github.com/eed3si9n/scalaxb/tree/master/cli/src/main/resources
There are various httpclients_dispatch0100_async.scala.template
. I think any template should provide a way to configure proxy through settings. I will add it to all of them.
I was going to add similar change to templates, but for timeout. See #304.
lazy val http = Http.configure(_.
setRequestTimeoutInMs(requestTimeout.toMillis.toInt).
setConnectionTimeoutInMs(connectionTimeout.toMillis.toInt))
Maybe you could do something like that?
That would be great, but I was not able to make it work. Tried:
lazy val http = Http.configure(_.setUseProxyProperties(true))
But the proxy settings are ignored. They are not ignored when I use the following: (I am a bit lost now)
lazy val http = new Http(new AsyncHttpClient(new NettyAsyncHttpProvider(new AsyncHttpClientConfig.Builder().setUseProxyProperties(true).build())))
The source code of Dispatch:
if (proxyServerSelector == null && useProxyProperties) {
proxyServerSelector = ProxyUtils.createProxyServerSelector(System.getProperties());
}
if (proxyServerSelector == null) {
proxyServerSelector = ProxyServerSelector.NO_PROXY_SELECTOR;
}
This is the cause why Http.configure(_.setUseProxyProperties(true))
won't work.
First time Http.apply() creates NO_PROXY_SELECTOR. and configure() calls build() second time causing proxyServerSelector == null && useProxyProperties
to be false.
I suggest modifying Http.configure
to not call build()
twice
I want to generate a soap client and test it, using service stub. I see there is an option to specify dispatch version, but still there is
InternalDefaults.client
used, making it unstubbable: http://stackoverflow.com/questions/28966315/stubbing-soap-requests-in-scalaSpecifying --blocking parameter uses the same AsyncHttpClient ignoring proxy settings, so it is still unstubbable.