square / okhttp

Square’s meticulous HTTP client for the JVM, Android, and GraalVM.
https://square.github.io/okhttp/
Apache License 2.0
45.75k stars 9.15k forks source link

Is it possible to avoid creating several clients? #2316

Closed danvinokour closed 8 years ago

danvinokour commented 8 years ago

I have a need to create several different clients since each one has different interceptors. I pass those clients to retrofit which mean that each time i use client.build() new client instance is created and memory is wasted. Is it possible to avoid creating many instances?

JakeWharton commented 8 years ago

More info is needed to answer this in any meaningful way. What are the interceptors doing that you need to change them constantly?

Also, this is probably much better served as a question on StackOverflow with the 'okhttp' tag...

danvinokour commented 8 years ago

Well, im my case i have one client which needs HeaderInterceptor, SignInterceptor and LoggingInterceptor. the other one needs only the Sign and Logging Interceptor and the third one needs only the Logging Interceptor.

But there easily could be cases in which i would need different header interceptors for different clients...

swankjesse commented 8 years ago

Please ask this question on StackOverflow. This tracker is for bug reports (with executable test cases!) and feature requests only.