API changes:
1) Added: Address.getCertificatePinner()
2) Incompatible API change: Address constructor no longer
includes ConnectionSpecs. Removed getConnectionSpecs().
3) Added: ConnectionSpec.isCompatible(SSLSocket)
4) Added: TlsVersion.javaName()
Implicit / semantic / internal changes:
1) Connection now handles all attempts to connect via a route
(effectively a {proxy, socket address} pair), rather than just
one attempt. i.e. Connection now handles all the TLS negotiation
fallbacks internally.
2) Route no longer deals with TLS versions. Individual TLS
failures are not counted against a Route. If no connection
attempts to a route were successful the failure is counted
against the route.
3) The code makes a distinction between when various
IOExceptions occur, with the intention making retries a bit
smarter. It is now more obvious which exceptions happen during
setup (RequestException), connection (RouteException),
HTTP communication and thus which can be retried and whether
the request might have been sent.
okhttp-android-support contains classes needed for Android embedding and
not for normal OkHttp development. The classes here can be excluded from
okhttp-urlconnection, shrinking that artifact. More classes will be
added to this component to make Android maintenance easier.
Also fix a bug in MockWebServer where calls to shutdown()
raced with calls to play() would throw a NullPointerException.
Also improve logging in MockWebServer.
This was present in a bunch of loops, but not all and not consistently. After fixing two, I figured that I would normalize them all under the umbrella of uniformity and being lazy (only lookup up the value once if it never changes).
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.
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.
This means we'll cache responses that use an 'Authorization' header. This
means OkHttp's cache shouldn't be used on middleboxes that sit between
user agents and the origin server; in practice this is never a use case
for OkHttp.
Fixes https://github.com/square/okhttp/issues/1035
When streaming a response, we copy data from our buffer to the cached file
on disk. Unfortunately we were copying N bytes from the front of the buffer
when we wanted N bytes from the back of the buffer.
Typically these are the same, but certain access patterns can cause them
to be different, corrpting the cached file on disk.
This was uncovered by migrating the cache tests from operating on
HttpURLConnection's API to our new API.
The HttpEngine would not obey the set state because there was no
correlation between the HttpURLConnection.setInstanceFollowRedirects
method and the OkHttpClient.
Fixed the missing link by adding a new setFollowRedirects method to the
OkHttpClient class. Bridged the gap for the HttpURLConnection.setInstanceFollowRedirects
by forwarding that state into the OkHttpClient.
Now the HttpEngine will always obey the OkHttpClient redirect state when
attempting the followUp phase.
Added necessary test to both OkUrlFactoryTest and CallTest.
https://github.com/square/okhttp/issues/943