-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code and documentation to use okhttp #17
Comments
@swankjesse, would it make sense to drop OkHttpModule in here, or maybe we should have a full-fledged sample app? |
We should fill out the README with example usage. For now, OkHttpConnection works exactly the same as HttpURLConnection: We'll also need to figure out how to hook up the HTTP response cache and document that. I'm hoping that its API also mirrors Android's built-in response cache. We still need to write the code. I'm hoping the API looks like this: Also outstanding on our end is to publish OkHttp to maven so end users can get .jar files. |
@pforhan great idea! We should publish OkHttpClient in its own maven module for folks interested in upgrading from Apache HTTP client. |
FWIW, I'm also interested in some docs & more samples. I'm trying to decide whether to use OkHttp or google-http-client for my android project and I'm really at a loss. I understand putting together docs & samples isn't really glamorous or exciting, but it would certainly be a great way to encourage usage and engagement by the community. If (in the meantime) someone has some some pointers for me, I'd very much appreciate that. |
We are working on these. Check back next week. For what it's worth, |
@JakeWharton I'm really glad to hear that. Everything seems simple enough for HttpURLConnection conn = client.open(server.getUrl("/"));
conn.setDoOutput(true); // this is redundant to setting requestMethod right?
conn.setRequestMethod("POST");
conn.setFixedLengthStreamingMode(n);
OutputStream out = conn.getOutputStream();
byte[] buf = new byte[writeKind == WriteKind.SMALL_BUFFERS ? 256 : 64 * 1024];
Arrays.fill(buf, (byte) 'x'); // xxxxxxxxxxxxxxxxxxxxxxxxx....
for (int i = 0; i < n; i += buf.length) {
out.write(buf, 0, Math.min(buf.length, n - i));
}
out.close(); |
Sending content is a bit more involved, yes. Check back next week :) |
Copy that. I'll try to make do until then. Unfortunately the Downloads page has no deployable jars and we decided to avoid the complexity of Maven setup with our project for now. There's also no simple build option so was wondering what you'd recommend for me to get started. |
Moreover, from searching maven, it seems there isn't even a jar in Maven that can satisfy the dependency (nothing with groupId of "com.squareup" and "okhttp"). I guess figuring out maven isn't so bad, but when trying to Sorry about all the questions. I don't want to pull |
Tests require Java 7. You can safely |
Awesome! Thanks so much @JakeWharton, I'm very grateful 😄 |
I have made a couple recent builds for my own work using okhttp which you can use for now: http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22io.tesla.okhttp%22%20AND%20a%3A%22okhttp%22 |
There are a few samples in |
There's no documentation or code that allows a potential users of okhttp to use it in an Android app or a regular, non-Android program. Such support code and documentation would sure be helpful.
The text was updated successfully, but these errors were encountered: