Previously we were assuming a field initializer wouldn't be
run until after the constructor. It wasn't and we were getting
NullPointerExceptions looking up the bufferPool.
This promotes Headers to a public API from the internal package.
It moves some of its methods to OkHeaders, which has been renamed
from SyntheticHeaders.
Making the Headers class public API makes it possible to remove
more exotic APIs from Request and Response like the APIs to track
headers by index rather than by name.
Re-using buffers can help avoid GC and make things run more smoothly when streaming data.
squash! Use AOSP ByteArrayPool to try and avoid buffer GC.
Copy tests over and attempt at better formatting.
squash! Use AOSP ByteArrayPool to try and avoid buffer GC.
ArrayDeque is <= API level 9 :-(
squash! Use AOSP ByteArrayPool to try and avoid buffer GC.
Another attempt at formatting.
fixup! squash! Use AOSP ByteArrayPool to try and avoid buffer GC.
Indent code properly attempt.
Now that we're preparing Content-Length and Transfer-Encoding
before passing a request to the HTTP engine, we have no strict
need to rewrite requests in the transport.
The nice upside of this change is that the transport becomes
even less obvious when it's in place.
This interface was necessary while cleaning up the delicate
intertwined relationship between HttpURLConnection and HttpEngine.
With this change HttpEngine no longer has a reverse dependency
on HttpURLConnection.
Move gateway timeout failures to CacheStrategy, and inline
methods nearby for a strict top-to-bottom flow in this method.
It becomes more obvious that the end of sendRequest has two
cases: we need a connection (opening if necessary) or we don't
need a connection (closing if necessary). Previously this was
true but not as explicit.
This renames ResponseStrategy to CacheStrategy and cleans up
the code that calls into it.
This fixes a bug where we were incorrectly reporting stats
when the caller was requesting only-if-cached. In those cases
we were tracking stats before applying that constraint. Tests
for these cases have been added
Now that Request and Response self-describe, I think the
word Headers is sufficient. And it's a lot less ugly than
RawHeaders.
Also move header serialization code to HttpTransport and
SpdyTransport.
Policy is a bridge to get us from a place where HttpEngine
depends 100% on HttpURLConnection to a place where it
doesn't.
We've refactored the code in HttpEngine enough now that
some Policy methods are no longer necessary. Delete 'em.
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.