You can set your own custom Apache HttpClient and HttpAsyncClient. Unirest leverages Apache Http Client under the hood, this is not considered to be a permemant requirement and future versions of Unirest may replace Apache with something else. This can be useful for logging or injecting common attributes. This is invoked before and after each request. You can set a global interceptor for your configuration. Set a default base URL to be used for all requests that do not already contain a scheme Set a custom HostNameVerifier for the security configuration
![java rest client download file java rest client download file](http://websystique.com/wp-content/uploads/2015/08/Spring4MVCFileUploadDownloadWithHibernate_img8.png)
Set a global Interceptor handler that will be invoked before and after each request Set a global error handler that will be invoked for any status > 400 or a parsing error No persistent connection will be re-used past its TTL value.Īdd total time to live (TTL) by Duration. Total time to live (TTL) defines maximum life span of persistent connections regardless of their expiration setting. Toggle to add the clients to the system shutdown hooks automaticallyĪdd a PKCS12 KeyStore by path for doing client certificatesĪdd a PKCS12 KeyStore for doing client certificates Toggle disabling automatic retries (up to 4 times) for socket timeouts Acceptable values: ‘default’ (same as Netscape), ‘netscape’, ‘ignoreCookies’, ‘standard’ (RFC 6265 interoprability profile), ‘standard-strict’ (RFC 6265 strict profile) Good for setting trace tokens for microservice architectures. Multiple for the same name can existĪdd a default header by supplier. Will overwrite if it existsĪdds a default header. Sets a proxy object for negotiating proxy servers. Sets concurrency rates max total, max per route Sets the connection timeout for all requests in millis Sets the socket timeout for all requests in millis Once Unirest has been activated configuration options that are involved in creating the client cannot be changed without an explicit shutdown or reset. There are several background threads spawned by both Unirest itself and Apache HttpAsyncClient. addInterceptor ( new M圜ustomInterceptor ()) Ĭhanging Unirest’s config should ideally be done once, or rarely. setDefaultHeader ( "Accept", "application/json" ). Sometimes it was done on Unirest, sometimes it was done on Option, sometimes it was somewhere else.Īll configuration is now done through nfig() Previous versions of unirest had configuration split across several different places. Public static void main ( String args ) Configuration