1
0
mirror of https://github.com/square/okhttp.git synced 2026-01-14 07:22:20 +03:00
Commit Graph

4471 Commits

Author SHA1 Message Date
Jesse Wilson
046f7f2450 Prepare for release 4.4.1. parent-4.4.1 2020-03-08 09:36:32 -04:00
Jesse Wilson
04c7303a1e Merge pull request #5861 from square/jwilson.0308.too_aggressive_
Don't reuse a connection on redirect if certs match but DNS does not (4.4.x)
2020-03-08 09:29:03 -04:00
Jesse Wilson
71046d45cc Don't reuse a connection on redirect if certs match but DNS does not (4.4.x)
We attempt to minimize connection and reconnection work, but in this case we
were overly aggressive about retaining the same connection. In some deployments
services will share certificates but not DNS addresses; when redirecting
between such services we were incorrectly attempting to reuse the connection.

This would have resulted in 404s and other misdirected requests.

Closes: https://github.com/square/okhttp/issues/5859
2020-03-08 09:18:02 -04:00
Jesse Wilson
7ea7c15e6b Merge pull request #5856 from square/jwilson.0307.no_trusts
Allow for users who have disabled certificate checks in dev. (4.4.x branch)
2020-03-07 13:58:37 -05:00
Yuri Schimke
f5d669cd0f Allow for users who have disabled certificate checks in dev. (#5835)
* Allow for users who have disabled certificate checks in dev.

* Avoid repeated calls

* typo

* Lock is assumed at this point

* Stay safe

* rework

* spotless

* Fix

* Handle one more case

* Capture the exception

* Add test

* Comment
2020-03-07 07:23:56 -05:00
Jesse Wilson
44124ba2a3 Prepare for release 4.4.0. parent-4.4.0 2020-02-17 17:51:22 -05:00
Jesse Wilson
3f946d0b13 Merge pull request #5795 from square/jwilson.0217.change_healthy_check
Be smarter about connection health checks
2020-02-17 16:45:46 -05:00
Jesse Wilson
19cb19ab4a Be smarter about connection health checks
Previously we didn't do any health checks at all until a
connection completed a single exchange. This was awkward
for HTTP/2, which could have multiple exchanges in-flight
before any were health checked.

We were also doing the awkward and expensive read timeout
check on all non-GET requests on pooled connections. Now
we only perform these checks if the connection was idle
for 10 seconds or more.

Closes: https://github.com/square/okhttp/issues/5547
2020-02-17 16:00:23 -05:00
Jesse Wilson
4e6699eb3b Merge pull request #5789 from square/jwilson.0216.give_up
Don't do infinite retries on server-canceled calls
2020-02-17 15:34:46 -05:00
Jesse Wilson
134ac98229 Don't do infinite retries on server-canceled calls
We originally had a bug where Call.cancel() would incorrectly
cause HTTP/2 connections to be closed.

The fix was to not consider HTTP/2 connections to be degraded
when a CANCEL error is received:
https://github.com/square/okhttp/pull/4052

This closes the loop to make sure that we only treat CANCEL as
expected when the call was actually canceled.

Closes: https://github.com/square/okhttp/issues/5726
2020-02-17 09:24:31 -05:00
Jesse Wilson
1c03efd4df Merge pull request #5792 from square/jwilson.0216.clear_out_next_route
Move the code that clears out the next route to try
2020-02-17 08:03:19 -05:00
Jesse Wilson
6bea51afa9 Merge pull request #5790 from square/jwilson.0216.cancel
Add a canceled event to EventListener
2020-02-17 07:52:39 -05:00
Jesse Wilson
54a6c665c0 Merge pull request #5793 from square/jwilson.0216.reliably_release
Use .use() writing metadata to the cache
2020-02-17 07:51:29 -05:00
Jesse Wilson
6da48a5487 Use .use() writing metadata to the cache 2020-02-16 22:15:05 -05:00
Jesse Wilson
c48e453778 Move the code that clears out the next route to try
I prefer the old code esthetically, but this has the behavior I want. The
core problem is we're deciding about nextRouteToTry too early, before a
failure makes that route ineligible.

Closes: https://github.com/square/okhttp/issues/5791
2020-02-16 21:17:04 -05:00
Jesse Wilson
08e23fcd02 Add a canceled event to EventListener 2020-02-16 18:20:49 -05:00
Jesse Wilson
4bb66bcf5e Merge pull request #5788 from square/jwilson.0216.null_host
Don't crash on a null host
2020-02-16 16:49:29 -05:00
Jesse Wilson
f00566f51d Don't crash on a null host
Closes: https://github.com/square/okhttp/issues/5770
2020-02-16 16:14:39 -05:00
Jesse Wilson
2479bd07c0 Merge pull request #5787 from square/jwilson.0216.limit_retries
Limit recovery attempts for REFUSED_STREAM errors
2020-02-16 16:06:52 -05:00
Jesse Wilson
5ba145aa6c Limit recovery attempts for REFUSED_STREAM errors
We limit per-connection retries but not per-call retries, so this was
creating large numbers of connections each of which called the server
and accepted yet another REFUSED_STREAM.

Instead we fail sooner with a StreamResetException.

This shows that the ExchangeFinder interface is still somewhat inadequate
to support all of the use cases we have.
2020-02-16 09:22:06 -05:00
Jesse Wilson
607c47a7e6 Merge pull request #5786 from square/jwilson.0215.defer_dns
Don't do proxy selection eagerly if we're pooling
2020-02-16 08:47:54 -05:00
Jesse Wilson
005daeb711 Don't do proxy selection eagerly if we're pooling
If we're going to end up using a pooled connection anyway we
should defer proxy selection until we need it.
2020-02-16 08:46:47 -05:00
Jesse Wilson
c5ac86b83a Merge pull request #5779 from yschimke/circleci_up
Latest CircleCI JDKs
2020-02-11 07:20:40 -05:00
Yuri Schimke
45bb3a58a9 Latest CircleCI JDKs 2020-02-11 07:03:49 +00:00
Jesse Wilson
8733411031 Merge pull request #5777 from square/jwilson.0209.tunnel_truncated
Add a test for truncated tunnel responses
2020-02-09 17:01:56 -05:00
Jesse Wilson
56fd46baa3 Add a test for truncated tunnel responses
As a happy accident this was fixed by yesterday's changes to tidy up
the exchange lifecycle.

Closes: https://github.com/square/okhttp/issues/5727
2020-02-09 16:18:03 -05:00
Jesse Wilson
23cdb3e9ab Merge pull request #5776 from square/jwilson.0208.http_421
Retry HTTP 421 exchanges on coalesced connections
2020-02-09 15:45:44 -05:00
Jesse Wilson
47503db955 Retry HTTP 421 exchanges on coalesced connections
Closes: https://github.com/square/okhttp/issues/5424
2020-02-09 15:44:56 -05:00
Jesse Wilson
6b7c35e275 Merge pull request #5775 from square/jwilson.0208.http421_
Formalize the lifecycle of Exchange
2020-02-09 13:06:40 -05:00
Jesse Wilson
0d09dc1238 Formalize the lifecycle of Exchange
There's four useful events:

1. When we're ready to call network interceptors. At this point
   we expect an exchange to exist, as a handle to the connection
   we've chosen for the network call

2. When we hold an exchange that must later be released.

3. When we release the exchange

4. When we're done calling network interceptors. Only at this point
   do we no longer need to remember what the exchange was and what
   connection it used.

In practice 1 and 2 happen mostly at the same time. Right now 1 is
in RetryAndFollowUpInterceptor and 2 is in ConnectInterceptor, but
we should be able to move those around without pain.

But we have a problem with 3 and 4. If the response has no response
body, then 3 will precede 4. We will release the exchange as soon as
we know there's no streams held. This means that network interceptors,
including our own RetryAndFollowUpInterceptor, do not consistently
have an exchange after they've called proceed(). This is problematic
if they want to make decisions based on what connection was used.

I've added a new member, 'interceptorScopedExchange' that holds the
exchange from 1 and 2 through 4, regardless of when 3 happens.

This is all working towards a solution to handling HTTP 421s on
coalesced connections.

https://github.com/square/okhttp/issues/5424
2020-02-09 13:06:13 -05:00
Jesse Wilson
0d213ba55c Merge pull request #5762 from rengwuxian/master
Remove always-false check of retryCurrentRoute() and unreachable code.
2020-02-05 21:36:33 -05:00
Liam Newman
78016071b3 Add a windows executor to the build (#5769)
* Add a windows executor to the build

* Disable failing tests on windows

* Workaround find limitations
2020-02-05 21:09:37 -05:00
Jesse Wilson
c2481103fd Merge pull request #5767 from square/jwilson.0202.fast_chain
Reorganize RealCall and RealInterceptorChain
2020-02-03 23:41:22 -05:00
Jesse Wilson
f567e5446a Reorganize RealCall and RealInterceptorChain
I've attempted to put RealCall's methods into a logical order; it's approximately
the order the methods get called in for a successful call.

For RealInterceptorChain I've created a copy() method inspired-by data classes.
This has the added benefit of shrinking the call stack everywhere.
2020-02-03 23:06:37 -05:00
Kai Zhu
5f94756dd2 Remove always-false check of retryCurrentRoute() and unreachable code. 2020-02-03 18:52:01 +08:00
Jesse Wilson
0604f39573 Merge pull request #5765 from square/jwilson.0202.exchanges
Fold together RealCall and Transmitter
2020-02-02 15:52:12 -05:00
Jesse Wilson
3d3b0f6400 Fold together RealCall and Transmitter
These two were 1:1 with each other and there were a few places in the code
where we had both. Putting them into the same class creates a class that
does has a lot of responsibilities, but I believe it's simpler overall than
having two classes.
2020-02-02 15:51:53 -05:00
Yuri Schimke
9e1a3da9ba Handle NoClassDefFoundError for Conscrypt (#5763) 2020-02-01 07:11:26 -08:00
Yuri Schimke
672e765cc8 Scope the RouteDB more precisely (#5758)
* Scope the RouteDB

* Cleanup

* Delete a commented out route database

Co-authored-by: Jesse Wilson <jesse@swank.ca>
2020-01-29 10:03:41 -05:00
Yuri Schimke
c6ef70148b Bouncy Castle Provider working with HTTP/2 on JDK 8 (#5751) 2020-01-29 00:19:32 -06:00
Jesse Wilson
41fb9a732f Merge pull request #5757 from square/jwilson.0126.okhttp_name
Use different thread names if OkHttp is shaded
2020-01-28 15:30:50 -05:00
Jesse Wilson
bd2c06dd4c Use different thread names if OkHttp is shaded
Closes: https://github.com/square/okhttp/issues/5632
2020-01-28 13:58:12 -05:00
Yuri Schimke
1b4cc4bb33 Explain prior responses issue for App Interceptors (#5752) 2020-01-25 15:05:02 -06:00
Yuri Schimke
6c9d741d4d Updated bug bounty (#5753)
* Updated bug bounty

* Fix the bugcrowd URL

* Fix the bugcrowd URL

* Restore the https:// in the bugcrowd URL

Co-authored-by: Jesse Wilson <jesse@swank.ca>
2020-01-25 14:52:57 -05:00
Yuri Schimke
97aa9f5425 Fix for BouncyCastle keyManager test (#5747) 2020-01-22 15:53:58 -06:00
Jesse Wilson
96b5f0c93d Merge pull request #5742 from square/jwilson.0120.bom
Publish a BOM for OkHttp 4.x.
2020-01-21 17:38:56 -05:00
Jesse Wilson
3f305a6859 Publish a BOM for OkHttp 4.x.
https://docs.gradle.org/current/userguide/java_platform_plugin.html

This prevents downstream applications from pulling in different
versions of various OkHttp subprojects.
2020-01-20 23:42:49 -05:00
Jesse Wilson
36a408b6d6 Merge pull request #5736 from square/jwilson.0119.mpp
Switch to Gradle's Maven Publishing Plugin
2020-01-20 22:50:30 -05:00
Jesse Wilson
a692bd663b Merge pull request #5741 from yschimke/bouncycastlefixes
Fixes for bouncycastle tests
2020-01-20 22:46:55 -05:00
Yuri Schimke
005c39b592 Fixes for bouncycastle tests 2020-01-20 22:47:13 +00:00