1
0
mirror of https://github.com/square/okhttp.git synced 2025-11-26 06:43:09 +03:00
Commit Graph

347 Commits

Author SHA1 Message Date
Jesse Wilson
1a68cf15af Provide better exceptions when the shared HTTP/2 stream fails
Previously we always provided a generic StreamResetException. Now we provide
the exception that triggered the stream to be closed, if any.
2019-03-12 09:21:02 -04:00
Jesse Wilson
e6cfc2a508 Apply whole-operation timeouts to setup of web sockets and duplex calls
https://github.com/square/okhttp/issues/4646

Still need to figure out SSE.
2019-02-26 09:38:31 -05:00
Amir Livneh
8dfb1b8557 Fix memory leak in MockWebServer when using ALPN
Since Platform.afterHandshake() was never called, SSLSockets were not removed from ALPN's Map and could not be freed.
2019-02-25 10:14:49 -05:00
Jesse Wilson
c8b1ee602b Support follow-ups for duplex requests.
https://github.com/square/okhttp/issues/4267
2019-02-23 11:05:58 -05:00
Jesse Wilson
e890ba6142 Test duplex with Expect/Continue 2019-02-23 09:31:18 -05:00
Adam Taft
5b3630f003 Delay loading default ServerSocketFactory until needed
ServerSocketFactory.getDefault() will load the default JVM truststore
(typically from jre/lib/security/cacerts) as configured by JSSE
system properties.

However, a typical use case for setting a custom ServerSocketFactory is
that the client application has loaded custom keystore or truststore
material into their JVM, usually by creating a custom SSLContext.

There's strictly no reason to initialize the default ServerSocketFactory
until the mockwebserver has been started, allowing custom settings of the
factory by clients and avoiding the default load attempt during class
construction.

This patch simply moves the initiatlization logic into the private start
method to avoid the premature loading of trust store materials.
2019-02-17 22:26:00 -05:00
Jesse Wilson
0a59e68b16 [maven-release-plugin] prepare for next development iteration 2019-02-05 12:15:46 -05:00
Jesse Wilson
d28d2cec21 [maven-release-plugin] prepare release parent-3.13.1 2019-02-05 12:15:39 -05:00
Jesse Wilson
5ecd590c8c [maven-release-plugin] prepare for next development iteration 2019-02-04 23:32:52 -05:00
Jesse Wilson
d55661544b [maven-release-plugin] prepare release parent-3.13.0 2019-02-04 23:32:45 -05:00
Jesse Wilson
392165d238 Improve testing in MockDuplexResponseBody 2019-02-03 21:56:39 -05:00
Jesse Wilson
94c38da706 Permit multipart filenames to contain non-ascii characters
Closes: https://github.com/square/okhttp/issues/4564
2019-02-02 12:55:32 -05:00
Jesse Wilson
3512ec5c9b Add tests that exercise real duplex communication
We're currently broken because the Pipe doesn't flush. Will fix in Okio.
2019-01-17 22:44:56 -05:00
Jesse Wilson
9d28d9c9e2 Get trailers working for HTTP/1
The most awkward part of this is the changes to the way MockResponse
handled chunked encoding. It used to consider trailers a part of its
chunked response; now it does not.
2019-01-14 22:33:54 -05:00
Jesse Wilson
778e0334a4 Use lambdas where appropriate 2019-01-11 22:31:36 -05:00
Jesse Wilson
5f4a2642c0 Use automatic-resource-management blocks. 2019-01-01 21:50:44 -05:00
Jesse Wilson
0dc50f1112 Run IntelliJ inspections on the codebase
Some nullability warnings, some diamond operators, adopting Objects.equals(),
and some dead code elimination.
2019-01-01 12:41:06 -05:00
Jesse Wilson
52e251836a Adopt some Java 8 features: diamonds, StandardCharsets 2019-01-01 00:48:07 -05:00
Jesse Wilson
8c2a4cfffa Don't crash on IPv4-mapped IPv6 addresses
https://github.com/square/okhttp/issues/4451
2018-12-29 18:32:07 -05:00
Jesse Wilson
555e621efe Merge pull request #4480 from square/jwilson.1228.customize_dispatcher
Add an API to access MockWebServer's dispatcher.
2018-12-28 19:15:25 -05:00
Jesse Wilson
1b1602d646 Add an API to access MockWebServer's dispatcher.
Closes: https://github.com/square/okhttp/issues/4383
2018-12-28 16:30:30 -05:00
Jesse Wilson
bf8e653c3a Get the latest versions of things.
I used 'mvn versions:use-latest-versions' and also just a bunch of manual
fixing.
2018-12-28 15:53:46 -05:00
Benoit Quenaudon
fa4a6ace63 Removed HttpSink and only expose just a sink instead 2018-12-18 10:23:10 -05:00
Benoit Quenaudon
dddbd58581 Trailers support for Http2 2018-12-18 08:55:52 -05:00
Benoit Quenaudon
7e9e57603e Allow Requests and Responses to communicate in duplex 2018-11-30 12:07:51 -05:00
Jesse Wilson
c273b3be38 [maven-release-plugin] prepare for next development iteration 2018-11-16 23:44:19 -05:00
Jesse Wilson
7f63a35ab1 [maven-release-plugin] prepare release parent-3.12.0 2018-11-16 23:44:12 -05:00
Benoit Quenaudon
3739c5cf20 Replaced List<Header> by a queue of Headers into Http2Stream 2018-10-22 14:38:07 -04:00
Benoit Quenaudon
c8cbb0d022 Send/Receive Headers via Http2 Frames 2018-10-12 18:32:03 -04:00
Yuri Schimke
077281796e Test for local port used in mock web server (#4246)
* Test for local port used

* fix checkstyle
2018-09-02 06:51:11 -04:00
Yuri Schimke
a01b511598 MockWebserver fix for IPv6 addresses (#4235)
Wrap IPv6 addresses with [] and return "/" path URIs for proxy CONNECT
2018-09-01 12:32:53 +01:00
Sergey Galkin
a146e50427 Shutdown MockWebServer after response (#4243) 2018-08-31 21:04:02 +01:00
Jesse Wilson
7ef5f55d38 [maven-release-plugin] prepare for next development iteration 2018-07-12 23:41:09 -04:00
Jesse Wilson
95ae0cf421 [maven-release-plugin] prepare release parent-3.11.0 2018-07-12 23:41:00 -04:00
Jesse Wilson
137e7de045 New API, HandshakeCertificates.addPlatformTrustedCertificates()
Also rename HeldCertificate.Builder.issuedBy() to signedBy(). 'Issued' is the
word used by certificates; 'signed' is the word used by cryptographers. I prefer
'signed'.
2018-07-12 10:51:33 -04:00
Jesse Wilson
37887141fe Rename TlsNode to HandshakeCertificates (#4141) 2018-07-12 06:39:20 +01:00
Jesse Wilson
b1bfe7130c New okhttp-tls module 2018-07-09 12:00:28 -04:00
Jesse Wilson
31c511f694 Rename SslClient to TlsNode and make it a public API
https://github.com/square/okhttp/issues/3934
2018-07-08 15:33:16 -04:00
Jesse Wilson
d908a676c2 Support client authentication in MockWebServer
Also expose the handshake in the RecordedResponse.

https://github.com/square/okhttp/issues/3934
2018-07-06 10:08:19 -04:00
Jesse Wilson
aac684aeae Retain interrupted state when throwing InterruptedIOException
The drawbacks seem small; the callsite needs to handle interruption anyway
because the thread is prone to interruption.

And the upside is that a single interrupt should now be sufficient to break
out an in-flight OkHttp call.

Note that although we're fixing this, thread interruption is not well tested
in OkHttp. Most users should prefer Call.cancel(), which is well tested and
doesn't rely on the caller to know which threads OkHttp is using to make
the actual HTTP request.

Closes: https://github.com/square/okhttp/issues/3945
2018-07-05 22:37:24 -04:00
Jesse Wilson
e983dd2ae0 HeldCertificate: a cert and its private key
This class has been in MockWebServer for a long time, but it's always been
in the internal package with an incomplete API. This change promotes it to
a public API.

It's not quite sufficient for use as-is; we also need to open source its
companion class 'SslClient' that represents who we trust (as a list of
root certificates) and who we are (as an optional held certificate plus
the chain to a root certificate).
2018-06-28 13:39:41 -04:00
Yuri Schimke
c3c9592474 better mock test fix 2018-06-17 15:13:34 +01:00
Yuri Schimke
327de18c95 Fix tests for now 2018-06-16 12:26:45 +01:00
Yuri Schimke
d66238d256 Use header delay instead of body delay before status line (#4011)
* Use header delay instead of body delay before status line
2018-05-29 19:10:12 +01:00
Jesse Wilson
db18f0e404 Rename H2C to H2_PRIOR_KNOWLEDGE. (#3996)
The string h2c is used with cleartext upgrades. We're not doing those here,
so that identifier isn't appropriate.
2018-05-12 01:29:21 -07:00
Jaye Pitzeruse
9a6f88dc34 gh-1019: Implemented prior knowledge approach to h2c (#3873) 2018-02-26 23:55:10 +00:00
Jesse Wilson
e86eb0e48b [maven-release-plugin] prepare for next development iteration 2018-02-24 13:33:57 -05:00
Jesse Wilson
c0739a4199 [maven-release-plugin] prepare release parent-3.10.0 2018-02-24 13:33:52 -05:00
Jesse Wilson
af6198a1e9 Fail HTTP/2 connections if the pong is not received. (#3878)
This removes the Ping abstraction from our http2 package. This was written as
if it were a public API, but never exposed to any callers but tests. Removing
it makes it easier to lock down how pings are used.

This also removes the NullServer class, replacing it with a new SocketPolicy
on MockWebServer. The new SocketPolicy, STALL_SOCKET_AT_START, allows us to
do TLS and negotiate an HTTP/2 connection without actually building a proper
Http2Connection and without responding to pings.

The behavior in HTTP/2 connections is modeled after our behavior in web sockets.
We count outgoing pings, incoming pongs, and confirm that the pongs are keeping
up. If later we make this policy more sophisticated we can track the changes
in both places.

Closes: https://github.com/square/okhttp/issues/3261
2018-02-22 18:37:34 -05:00
Jesse Wilson
6c66d6c41b Fail web sockets if the pong is not received (#3870)
There are several options for when to expect the pong response. I've
chosen to overload the ping interval. This seems reasonable because the
ping interval is the maximum amount of time that should elapse before
a connection failure is detected.

Closes: https://github.com/square/okhttp/issues/3227
2018-02-20 15:02:29 -05:00