Skip to content
This repository has been archived by the owner on May 1, 2023. It is now read-only.

When stetho support OkUrlFactory ? ( volley+okhttp+stetho support ) #77

Closed
clarkshu1016 opened this issue Mar 1, 2015 · 3 comments
Closed

Comments

@clarkshu1016
Copy link

I use the volley +okhttp. Implement Android Volley with OkHttp 2.2 using OkUrlFactory .
but from the https://github.com/square/okhttp/wiki/Interceptors ,at last ,it'said

Availability

OkHttp's interceptors require OkHttp 2.2 or better. Unfortunately, interceptors do not work with OkUrlFactory, or the libraries that build on it, including Retrofit ≤ 1.8 and Picasso ≤ 2.4.

public class OkHttpStack extends HurlStack {
   private final OkUrlFactory okUrlFactory;
   public OkHttpStack() {
       this(new OkUrlFactory(new OkHttpClient())); 
   }
   public OkHttpStack(OkUrlFactory okUrlFactory) {
       if (okUrlFactory == null) {
           throw new NullPointerException("Client must not be null.");
       }
       this.okUrlFactory = okUrlFactory;
   }
   @Override
   protected HttpURLConnection createConnection(URL url) throws IOException {
       return okUrlFactory.open(url);
   }
}

@jasta
Copy link
Contributor

jasta commented Mar 2, 2015

Volley can be supported a few different ways. There's discussion of a generic solution in #51, but the currently preferred solution for okhttp specifically is with a new OkHttpStack implementation: https://gist.github.com/bryanstern/4e8f1cb5a8e14c202750.

@jasta jasta closed this as completed Mar 2, 2015
@amadib
Copy link

amadib commented May 8, 2016

@jasta Considering Apache HTTP Client Removal, how would our HttpStack look without having useLibrary 'org.apache.http.legacy'?

@lemoclone
Copy link

For stetho 1.3.1, redirect the http request by get the http request's header and body, (if just for test),here is the implementation: https://github.com/lemoclone/volley/blob/master/src/main/java/com/android/volley/toolbox/OkHttpStack.java

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants