Just hard-coding 'localhost' is simpler and avoids problems where
the host machine's IP address has additional DNS registrations.
Closes: https://github.com/square/okhttp/issues/7603
* Public API for duplex streams in MockWebServer
I'm not 100% on the name 'Stream' for the source+sink pair. It's
tempting to use 'Socket', though I think that's an implementation name
and this is an abstraction that uses a different implementation.
I've chosen Stream specifically 'cause it's the word used in the
HTTP/2 spec. My biggest gripe with it is that it's bidirectional
in the HTTP/2 spec, but Java InputStream and OutputStream are not
bidirectional.
* Dump APIs for streams
* Don't include a Content-Length header for chunked bodies
* Convert MockWebServerTest to Kotlin (#7596)
* Rename .java to .kt
* Convert Java to Kotlin
* Null isn't special for last-write wins
* Attempt to make NonCompletingRequestBody less flaky
* Create MockResponseBody
We'd previously only ever used Buffer to model the type
of the MockResponse body. This has proven inadequate, particularly
for features like duplex responses.
Most of the complexity in this PR is changing how throttling
and disconnect-during-body work when we don't necessarily have
a Buffer for the response body.
This is a first step, more capability to follow.
* Update API
* We flush fewer times now
* Attempt to make a test less flaky
* Try harder to make the test less flaky
* Switch to a Builder for mockwebserver3.MockResponse
* Migrate lots of tests to MockResponse.Builder
* Improve some code style
* Follow naming conventions in MockResponse.Builder
* Apply side-effects for inTunnel=true
* Update the API
* Implement CONNECT tunnels for HTTP/2 prior knowledge
Closes: https://github.com/square/okhttp/issues/7289
* Update the API spec for MockWebServer
* It is okay for HTTP/2 prior knowledge to send data early
Tests were failing due to an overly-pessimistic 'too much buffering'
exception. I moved the detector to where it's actually needed.
* Change how HTTP 1xx responses work in MockWebServer
Previously this was a SocketPolicy. With this change each
response may carry 0 or more informational responses which
are transmitted before the ultimate response.
* Add a test for multiple 1xx responses
* Update API
This is the only behavior change in the PR. The rest is converting
a test from Java to Kotlin (so it can see this internal member) and
getting a TaskRunner instance into the ExchangeFinder, hopefully
useful for implementing Happy Eyeballs.
Also fix up some formatting problems.
Also migrate some tests that use these Util functions from Java to Kotlin.
If we're going to make OkHttp multiplatform, our tests need to be Kotlin
so we can run them on all supported platforms.
I attempted to do a literal translation as much as possible.
Subprojects now need plugins to be configured directly so they
can use the appropriate syntax.
Previously we did a reverse DNS lookup. But the correct strategy
is to look at the inbound ':authority' (HTTP/2) or 'Host' (HTTP/1)
header.
See: https://github.com/square/okhttp/pull/6774