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
* 15characterlimi-null-sslsocketfactory:
First step towards HTTP/2 automatic pings. (#3874)
Fix swapped name and value tests. (#3877)
OkHttpsURLConnection.setSSLSocketFactory(null): throw.
This changes the executor services in HTTP/2 connection to split up
listener executors (of which there may be many threads) from writer
executors (of which there is one per connection).
This adds a scheduled executor job to send pings on an interval. We
don't yet fail the connection if pongs are not received.
For follow-up there's some work to remove exising APIs to send pings
through the HTTP/2 APIs. These are unused and make it awkard to
confirm that only the automatic pings are being replied to.
See https://github.com/square/okhttp/issues/3261
This changes the executor services in HTTP/2 connection to split up
listener executors (of which there may be many threads) from writer
executors (of which there is one per connection).
This adds a scheduled executor job to send pings on an interval. We
don't yet fail the connection if pongs are not received.
For follow-up there's some work to remove exising APIs to send pings
through the HTTP/2 APIs. These are unused and make it awkard to
confirm that only the automatic pings are being replied to.
See https://github.com/square/okhttp/issues/3261
OkHttpsURLConnection extends javax.net.ssl.HttpsURLConnection.
The super class documentation says that setSSLSocketFactory(null)
throws IllegalArgumentException, but this implementation didn't
do that.
This CL fixed OkHttpsURLConnection.setSSLSocketFactory(null) to
throw, as specified.
Test: not done locally, relying on Travis.
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
This breaks our concurrency rules. Fortunately it's only academic; only
MockWebServer ever writes settings, and it only does so in very specialized
tests.
Though it's good for OkHttp to retain the user's provided encoding, we
should be encoding more characters than we are when the user provides
us with unencoded data.
Closes: https://github.com/square/okhttp/issues/3235
* Add a failing test for handling 100 response when it was not requested
(#3628)
* Implement reading the correct response after unrequested 100-continue
* Eliminate redundant boolean.
* Force batch web socket emissions to underlying sink.
Write directly into the sink's buffer so that we can ensure there are no accidental emissions to the buffered sink's underlying sink. Since we always call flush() or emit() at the end of these methods anyway, accidental intermediate emissions don't have any performance value.
* Private.
* Remove unused constants.
* Initialize byte arrays for masking only when needed.
* Move frame byte read count to locals.
* Re-use Buffer instances for control and message frames.
* Remove test dependency on implementation code.
Previously the test used logic that was part of the code under test to validate behavior. This means that a bug would be missed as the behavior would be present in the actual and expected data. By using golden binary hex values, we are insulated from this.
It was possible for a call to cancel() to not cancel because the canceling
thread wouldn't observe the streams.
I've added a local StreamAllocation variable to avoid extra volatile reads.
Closes: https://github.com/square/okhttp/issues/3834
* (in-progress) Support gzipped bodies as a networkInterceptor
* Fixed buffer cloning, added test for a still-unsupported encoding (Brotli)
* Avoid try-with-resources and too-long lines to appease build checks
* Fixed method name typo
* Added suggested comma between byte and gzipped-byte count
* Account for added comma in test
* Use buffer.writeAll to ensure all body content is read
* Indentation consistency
* Added test to confirm response body remains valid
The use of Common Name was deprecated in RFC 2818 (May 2000), section 3.1:
Although the use of the Common Name is existing practice, it is
deprecated and Certification Authorities are encouraged to use the
dNSName instead.
In 2017, Chrome 58, Firefox 48, and Opera 45 web browsers removed this
fallback, with Chrome leaving it configurable for enterprise deployments
(see https://www.chromestatus.com/feature/4981025180483584).
Android is removing it in http://r.android.com/581382 .