Sometimes we name a thread both via its ExecutorService
and via a NamedRunnable. The ExecutorService thread needs
to be named because threads are cached and will be visible
in a thread dump even when no runnables are running.
NamedRunnables are also used because they provide additional
context: the host or URL being serviced by a thread.
The request line is now standalone because it depends
on the proxy (for full URL or not) and the connection
(for HTTP version). I may change this later and put
this info in the request.
The status line now moves into Response. I have a
helper class StatusLine that does the parsing. I may
later want to hide this or make it public; I'm not
quite sure yet!
The net result is that RawHeaders is getting dumber
and used in fewer places, which is good news. This
change also shows nice simplifications to the
authenticator (which needs fewer args) and to the
tunnel builder.
Also fold together HttpsEngine and HttpEngine; the
HTTPS subclass wasn't pulling its weight.
I needed a non-terrible way to provide the HTTPS handshake
information to the async API. Previously we were passing the
live socket around, which was leaky and gross.
This creates a new value object that captures the relevant
bits of the handshake. We can use it in the response, the
connection, and also in the cache. It's plausible that in
the future we can use it to allow the application to block
requests if the handshake is insufficient.
This was causing some SPDY connections to be evicted early,
and preventing connection reuse.
The spdyConnectionReuse test becomes flaky with the
fix that makes MockWebServer use different sequenceNumbers
for different requests on the same socket. With the fix
the test is no longer flaky. The old test wasn't good enough
to detect what it wanted to detect!
This race has existed in the code since we added more
aggressive time-based expiration in January 2013. In my
basic tests the race impacted ~20% of connections on a
desktop VM. It may have been more on mobile.
This behavior-free refactoring makes the first baby steps towards
supporting HTTP/2.0. It adds indirection on the framing layer so
we can frame either using SPDY/3's syntax or HTTP/2.0's.
To build HTTP/2.0 support into OkHttp I'm going to simultaneously
build HTTP/2.0 support into MockWebServer. To make that possible,
I'm first going to fork MockWebServer and then combine it with
MockSpdyServer.