1
0
mirror of https://github.com/square/okhttp.git synced 2025-11-27 18:21:14 +03:00
Commit Graph

296 Commits

Author SHA1 Message Date
Jake Wharton
c46b61d565 Use 'Headers' in recorded response. 2015-01-05 22:38:23 -08:00
Jake Wharton
8f54a48ea5 Clean up time-based APIs for throttle and delay. 2015-01-05 09:34:33 -08:00
Jesse Wilson
f84c2c022a Merge pull request #1290 from square/jw/start
Rename play to start.
2015-01-05 10:32:51 -05:00
Jake Wharton
c5c4e7857c Expose Headers directly on MockResponse. 2015-01-05 00:42:01 -08:00
Jake Wharton
8e201297fe Update MockWebServer to use Headers. 2015-01-05 00:18:56 -08:00
Jake Wharton
5355762a6f Rename play to start. 2015-01-04 23:17:42 -08:00
Jake Wharton
9a5670beec Change MockResponse body to Source. 2015-01-04 22:05:47 -08:00
Jake Wharton
7a279cb385 Make cache-control remember its header value. 2015-01-04 17:07:31 -08:00
Jake Wharton
8b0bdf3155 Teach MockWebServer to speak WebSockets. 2015-01-04 00:52:22 -08:00
Jake Wharton
7361b9a141 Prefer JUnit rules for temporary folders, MockWebServer. 2015-01-02 18:00:23 -08:00
Jesse Wilson
b2c657b157 Test Expect: 100-continue with OkHttp, not HttpURLConnection.
This test is flaky when relying on the platform's built-in
HttpURLConnectionImpl.

Instead, test it with OkHttp's API and implementation.
2015-01-02 17:57:41 -05:00
Jake Wharton
8b6aa0dca5 Use a Buffer for body contents. 2015-01-02 14:03:25 -08:00
Jake Wharton
4a3226a711 Use TlsVersion enum for recorded requests. 2015-01-02 13:43:13 -08:00
Jake Wharton
9b05d82d03 Merge pull request #1267 from square/jw/headers-add-line
Promote adding headers by line to public API.
2015-01-02 12:45:41 -08:00
Jake Wharton
c202640e12 Promote adding headers by line to public API. 2015-01-02 12:38:25 -08:00
Jesse Wilson
7049b29fd5 Always include OkHttp in thread names. 2015-01-02 13:46:55 -05:00
Jake Wharton
9631227619 Add a web socket call concept for connecting.
Similar to HTTP and Call, the WebSocketCall is a representation of a pending HTTP request and subsequent upgrade to speak web sockets. Upon synchronous execution you are handed a WebSocket instance for synchronous writing and also pass in a WebSocketListener for async callbacks due to reading.

The API changes in this commits also generalize WebSocket such that it's agnostic to being a client or server peer.
2014-12-31 23:13:07 -08:00
Jesse Wilson
1d86439e90 [maven-release-plugin] prepare for next development iteration 2014-12-30 21:52:35 -05:00
Jesse Wilson
6aef5ab3c5 [maven-release-plugin] prepare release parent-2.2.0 2014-12-30 21:52:33 -05:00
Jesse Wilson
786e3b3048 New API to disable retry for an OkHttpClient.
Most applications won't want to disable retry globally. Instead, use
clone() to get an OkHttpClient for a specific, non-idempotent request,
then configure that client with the setting.

Closes https://github.com/square/okhttp/issues/1043
2014-12-30 20:31:32 -05:00
Jesse Wilson
24750b59c4 Merge pull request #1256 from square/jwilson_1230_followup
Limit 20 authorization attempts.
2014-12-30 17:18:44 -05:00
Jesse Wilson
e49dd7a2f0 Limit 20 authorization attempts.
We use one count for both redirects and authorization attempts. This
seems like good enough policy.

Closes https://github.com/square/okhttp/issues/960
2014-12-30 12:14:49 -05:00
Jesse Wilson
dcbb199247 Don't recover from timeouts.
Closes https://github.com/square/okhttp/issues/1146
2014-12-30 10:37:09 -05:00
Jesse Wilson
b6a8da414b Merge pull request #1254 from square/jwilson_1229_opt_into_caching
Cache 302s and 308s with the right response headers.
2014-12-29 19:29:29 -05:00
Jesse Wilson
1d6f0e75d5 Cache 302s and 308s with the right response headers.
Closes https://github.com/square/okhttp/issues/1158
2014-12-29 18:47:36 -05:00
Jesse Wilson
a409634d36 New APIs to iterate the response cache.
Closes https://github.com/square/okhttp/issues/853
2014-12-29 17:19:41 -05:00
Jesse Wilson
452b3190b2 Merge pull request #1250 from square/jwilson_1229_cache_iterator
New API for iterating DiskLruCache contents.
2014-12-29 14:30:26 -05:00
Jesse Wilson
755bd91f75 New API for iterating DiskLruCache contents.
For https://github.com/square/okhttp/issues/853
2014-12-29 14:24:09 -05:00
Jesse Wilson
98c74ace40 Respect the max idle connections limit.
The structure here is a bit ugly. But it permits a single 'synchronized'
block, which makes the method easier to reason about.

Closes https://github.com/square/okhttp/issues/1239
2014-12-29 10:10:00 -05:00
Jesse Wilson
39971631fe Support SOCKS proxies.
The trickiest part of this change is the SOCKS 5 proxy implemented
to make testing possible. Fortunately the protocol is very easy, and
shows off Okio.

Closes https://github.com/square/okhttp/issues/1009
2014-12-28 12:07:21 -05:00
Jesse Wilson
0de100dc1e Fix pooling with proxy selectors.
Previously two OkHttpClients that shared a connection pool but
used different proxy selectors could incorrectly share the
pooled addresses.

Closes https://github.com/square/okhttp/issues/1149
2014-12-27 20:05:59 -05:00
Jesse Wilson
785d9e9438 Use MockWebServerRule in more tests.
Also fix a bug in MockWebServer where calls to shutdown()
raced with calls to play() would throw a NullPointerException.

Also improve logging in MockWebServer.
2014-12-27 13:05:36 -05:00
Jesse Wilson
050eb79163 Merge pull request #1243 from square/nfuller_ChangeAlpnNpnSupport
Nfuller change alpn npn support
2014-12-26 18:13:28 -05:00
Jesse Wilson
955934836f Merge remote-tracking branch 'nfuller/ChangeAlpnNpnSupport' into nfuller_ChangeAlpnNpnSupport
* nfuller/ChangeAlpnNpnSupport:
  Remove NPN support from OkHttp

Conflicts:
	okhttp/src/main/java/com/squareup/okhttp/Protocol.java
	pom.xml
2014-12-26 18:12:57 -05:00
Jake Wharton
58baa85208 Merge pull request #1236 from square/jwilson_1225_response_body
Source-incompatible: RequestBody.contentLength() throws IOException
2014-12-26 03:09:53 -08:00
Jesse Wilson
0d8704e252 Merge remote-tracking branch 'nfuller/FixPoolLeak' into nfuller_FixPoolLeak
* nfuller/FixPoolLeak:
  Fix for a socket leak in OkHttp on Android

Conflicts:
	okhttp-tests/src/test/java/com/squareup/okhttp/ConnectionPoolTest.java
	okhttp/src/main/java/com/squareup/okhttp/ConnectionPool.java
2014-12-26 01:15:51 -05:00
Jesse Wilson
9f5951b311 Merge pull request #1225 from square/jw/roundabout-kill
Increase determinism in DiskLruCache tests.
2014-12-26 00:45:39 -05:00
Jesse Wilson
0a4e510a94 Source-incompatible: RequestBody.contentLength() throws IOException
This is a binary-compatible change, but code that currently calls
RequestBody.contentLength() doesn't necessarily catch or declare
IOException, and will need to with this change.

MultipartBuilder is most impacted by this change; previously the
length was computed eagerly; now it's not computed at all.
Applications that require the previous behavior should fully
buffer the request bodies and use that to compute the length.

Closes https://github.com/square/okhttp/issues/1141
2014-12-25 23:44:05 -05:00
Jake Wharton
3f8aa8c8b0 Merge pull request #1235 from square/jwilson_1225_fix_npe
Don't NPE if disconnecting before connecting.
2014-12-25 18:21:37 -08:00
Jesse Wilson
0e199f6089 Don't NPE if disconnecting before connecting.
Closes https://github.com/square/okhttp/issues/1191
2014-12-25 21:05:36 -05:00
Jake Wharton
8e0a87a374 Use a name more appropriate for both SPDY and HTTP/2 connections. 2014-12-24 13:47:38 -08:00
Jake Wharton
1cabb0f58e Move method to test module, its only place of use. 2014-12-24 12:02:29 -08:00
Jake Wharton
67ac248168 Increase determinism in DiskLruCache tests.
This kills a flaky test by dependency injecting the executor and using a test executor as a stronger signal.
2014-12-23 13:16:24 -08:00
Jesse Wilson
41bee9b70d More interceptor tests.
Test interactions with the response cache and HttpURLConnection.
2014-12-23 00:24:15 -05:00
Jesse Wilson
27c6e69c82 Network interceptors.
These exist between the OkHttp features (gzip, response cache, retry, route
planning, etc.) and the network server. They can be used to rewrite the response
headers and body from what the server actually returned to what the client wants.

For example, the interceptor could inject a missing 'Cache-Control' header to make
caching work better.
2014-12-22 13:45:25 -05:00
Jesse Wilson
e74e3f3bf7 Move cache writing out of the transport.
This is necessary to unblock network interceptors, where the interceptor
may elect to rewrite the response body. If we've already cached the
original response body, we're too late.
2014-12-21 21:21:55 -05:00
Neil Fuller
a8327d121b Fix for a socket leak in OkHttp on Android
When the preferred Android network changes from
cell -> wifi or wifi -> cell the HTTP connection
pool in use is abandoned to avoid reuse of
connections on the old network. This was added
in commit 8bced3e.

The design for the connection pool was such that
continuous use of the connection pool was required to
clean up idle / expired connections. If a connection
pool becomes idle (as when it is dereferenced on a
network change) it is possible for some connections
to remain in the pool indefinitely.

After the preferred network change, because the old
connection pool was no longer referenced the pool
would be garbage collected and Android's "Strict Mode"
would complain about sockets not being closed.

The only existing way to avoid this was to call
"evictAll()", which would have had issues when a
large number of connections were returned to the pool
after evictAll() was called. It also wouldn't work
for SPDY connections which are shared but not reference
counted, which makes knowing whether it is safe to
close them difficult.

The cleanModeRunnable serves two purposes:

1) While scheduled / executing, it pins the connection
pool in memory to avoid it being garbage collected.
2) It continues to close connections (safely) until the
pool is empty.

If a connection is then added back to the pool the
cleanModeRunnable is restarted.
2014-12-18 16:19:06 +00:00
Neil Fuller
6ffd38e928 Adding TLS_FALLBACK_SCSV support
This is to upstream changes made in Android for
the POODLE vulnerability.
2014-12-17 15:50:06 +00:00
Jesse Wilson
24aa4e8970 Merge pull request #1205 from square/jw/one-one-oh
Update to Okio 1.1.0.
2014-12-15 22:44:42 -05:00
Jake Wharton
117ebac9e2 Update to Okio 1.1.0. 2014-12-15 19:26:51 -08:00