Closed kliakos closed 5 years ago
+1 Per-request settings are a must if one wants to use Unirest in a library. I cannot force my library user's to use my custom timeout or HttpClient, and I cannot depend on them not changing the settings I need
There's a fork that supports per-request HttpClient: https://github.com/r-murphy/unirest-java/commit/65f6518a5434013da7122dd90e1f6dd26daa20f3
Is this now possible?
Sort of, you COULD make a different config per request but I wouldn't recommend that at all. Configuring a client is pretty expensive and it's surely not worth it for on the fly changing of socket timeouts.
The underlying Apache Http Client doesn't support this so officially Unirest will not either until the Apache client changes or we move to not use Apache.
Overriding the RequestConfig
on the RequestBuilder
does the trick for Apache Http Client. Not sure why you say it is expensive. You don't configure the HttpClient
, but the HttpRequest
only.
Ah, I didn't know that was there. I'll reopen
bah, I did know it was there, now I feel dumb. Hold on I'll have this done this weekend
released in 2.0.05
Wouldn't it be nice if you could set a custom SocketTimeout per each request?
Currently you can only set it globally.