Comments (13)
@swankjesse, would it make sense to drop OkHttpModule in here, or maybe we should have a full-fledged sample app?
from okhttp.
We should fill out the README with example usage. For now, OkHttpConnection works exactly the same as HttpURLConnection:
URL url = ...
OkHttpConnection httpConnection = OkHttpConnection.open(url);
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:
File httpCacheDir = ...
long httpCacheSize = ...
OkHttpResponseCache.install(httpCacheDir, httpCacheSize);
Also outstanding on our end is to publish OkHttp to maven so end users can get .jar files.
from okhttp.
@pforhan great idea! We should publish OkHttpClient in its own maven module for folks interested in upgrading from Apache HTTP client.
from okhttp.
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.
from okhttp.
We are working on these. Check back next week.
For what it's worth, OkHttpClient
is all you need to look at. 99% of everything else is covered by normal HttpUrlConnection
and HttpsUrlConnection
's APIs.
from okhttp.
@JakeWharton I'm really glad to hear that. Everything seems simple enough for get
requests, but I'm a bit unclear on post
requests. I was hoping for a simple setContent
API or something like that, but from perusing the tests, it seems a bit more involved, eg (with some branches removed):
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();
from okhttp.
Sending content is a bit more involved, yes. Check back next week :)
from okhttp.
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.
from okhttp.
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 maven package
to build a jar I can use, tests fail with 63 errors. I can skip tests of course but is that wise? Are the failing tests failing because my environment isn't setup properly or because the project is actually broken? If it's actually broken right now, do you know of the last green SHA?
Sorry about all the questions. I don't want to pull google-http-client
into my project only to switch it out for okhttp next week. I guess I was idiotic to start writing code that depends on a library I didn't have in my libs
dir yet. ๐
from okhttp.
Tests require Java 7. You can safely mvn clean install -DskipTests
(or package) for now. We verify them on every pull.
from okhttp.
Awesome! Thanks so much @JakeWharton, I'm very grateful ๐
from okhttp.
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
from okhttp.
There are a few samples in master
and a documentation website that is now live (and will be expanded on).
from okhttp.
Related Issues (20)
- The request body data added in the NetworkInterceptor was found not included in the capture by Charles. HOT 1
- The request body data added in the NetworkInterceptor was found not included in the capture by Charles
- Gzip/Deflate/Bortli not workin okhttp3 4.12.0/5.0.0-alpha12 HOT 5
- DiskLruCache entry?.currentEditor is allways not null for async requests HOT 1
- Documentation: Clearly state that OkHttpClient should be a singleton HOT 6
- downloading big file midway Report an error java.net.ProtocolException: unexpected end of stream HOT 1
- Investigate Lock vs Synchronized performance HOT 4
- okhttp-coroutines in alpha 13 contains core classes HOT 1
- okhttp3.internal.http2.StreamResetException: stream was reset: CANCEL HOT 1
- HTTPS proxy support HOT 17
- Cannot instantiate MockWebServer on alpha 14โ: java.lang.NoClassDefFoundError: okhttp3/internal/_UtilJvmKt HOT 3
- Failing while building okhttp version parent-3.6.0 using mvn clean install HOT 1
- QUERY support
- No callbacks: no successful callbacks and no failed callbacks HOT 4
- TaskRunner's concurrent performance exhibits a significant decline in case of poor networks conditions HOT 12
- Calling response.body.string() on a MockWebServer response throws a SocketTimeoutException HOT 5
- java.net.SocketException: socket is closed HOT 11
- UTF-32LE and UTF-32BE BOM are incorrect
- Huffman : Fatal Exception: java.lang.NullPointerException HOT 3
- Delayed sending request HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from okhttp.