Skip to content

Instantly share code, notes, and snippets.

@LOG-TAG
Created July 25, 2014 07:58
Show Gist options
  • Save LOG-TAG/3233bb88ddb7e6c954ea to your computer and use it in GitHub Desktop.
Save LOG-TAG/3233bb88ddb7e6c954ea to your computer and use it in GitHub Desktop.
OkHttpStack for OkHttp 2.0.0
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);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment