History log of /libcore/luni/src/main/java/libcore/net/http/HttpEngine.java
Revision Date Author Comments
b11e44a402eb0f9c5da1f7482fc1eabdd9adff47 20-Sep-2012 Jesse Wilson <jwilson@squareup.com> Fix a bug in tunnel construction and 'Connection: close' headers.

Based on https://github.com/square/okhttp/pull/30
(git fetch git://github.com/square/okhttp.git && git cherry-pick -x b8c51dc5bdc89d5487cbc110d6fe40389de16480)

Bug: http://code.google.com/p/android/issues/detail?id=37221
Bug: 7291446

(cherry picked from commit 4bedacd569fed2db56c518ed239412b3fe32245e)

Change-Id: I68c55e9259db91dbccca30824c00726094570304
6d41a7cc3cb4cc684c8bece69ddc55954812ad6e 24-Sep-2012 Narayan Kamath <narayan@google.com> Strip content length in requests with "transparent" gzip handling.

We need to strip both the Content-Length and the Content-Encoding
for such requests. In such requests, it will be the length of the
compressed response. We hide the fact that compression is taking place
from clients, so we shouldn't give them the content length either.

(cherry picked from commit f9d60aed414ae21811a6488f603333517f257b22)

Change-Id: Ic2776ecf020c34b1c55e2fb7e2f0728e553187a0
fddea0213028dd6d467f316584fac0f6e0745ce9 31-Jul-2012 Elliott Hughes <enh@google.com> HttpResponseCache should return 504, not 502.

The RFC seems pretty clear on this issue.

Bug: http://code.google.com/p/android/issues/detail?id=28294
Change-Id: Ia9a979e1fbbd8b38b1607059c042e0fc9ca44270
4ec2d0dea800397fb32227e0631246f4d2a73191 29-Jun-2012 Brian Carlstrom <bdc@google.com> HttpEngine should not attempt to cache proxy CONNECT responses

This fixes an issue where a bad proxy repsonse that included a body
would turn into an IllegalStateException instead of an IOException.

Bug: 6754912

Change-Id: I204ad975820693d6add2780d7b77360463e33710
e636ca4d6bd101324bd95fbc817401e6e0b80a2c 15-Feb-2012 Jesse Wilson <jessewilson@google.com> Introduce an ExtendedResponseCache interface.

We had an ugly bug where HttpEngine was inspecting its response
cache's implementation type, and calling stats tracking methods
if that type permitted it.

This worked for all the libcore tests, but not in practice since
the public HttpResponseCache class WRAPS the libcore HttpResponseCache.
The new interface makes the new APIs called by HttpEngine on its
cache explicit, and permits the public android.net.HttpResponseCache
to implement the API.

Bug: http://code.google.com/p/android/issues/detail?id=25418
Change-Id: Ic9697af96635256e7ffc24f86628a85fbe2defd4
df29c7dc69965462cd19de8910b04c8cb463e57f 15-Feb-2012 Jesse Wilson <jessewilson@google.com> Don't attempt to parse an HTTP response body on HEAD requests.

Previously if the response had a Content-Length or Transfer-Encoding
header we assumed it had a body. This was untrue of HEAD requests.
This is not a regression.

Bug: http://code.google.com/p/android/issues/detail?id=24672
Change-Id: I264db2014e681a6f8e93cd40b0f1640c95103d21
a468471e8ccc2f642d5b2ae3c75873a74267ece2 26-Jan-2012 Jesse Wilson <jessewilson@google.com> Don't throw needlessly when returning the CacheResponse.

We were throwing under the premise that we'd always have
response headers before we had a cached body. But when the
user calls connect() we'll have queried the cache but we
won't necessarily have response headers from the server yet.
That's because connect() doesn't require a response to be ready.

Bug: http://b/5920659
Cherry-picked from: I9d69b44b5be3d0e29f14d8b83781f6e65c67582a

Change-Id: Ia403b42ddc9783fd1456164f4b7350da3ce80566
5d7e0fc1af3141aa41e9c21d74da3c36b933517f 23-Dec-2011 Jesse Wilson <jessewilson@google.com> Update the response cache on a conditional cache hit

Bug: http://b/4460598
Change-Id: I5f274b2109861b9d2ed59eda8b3e5b4e89fd27b3
fa5e8dfe3c7ed144b0fbe69091628dedd6a3b961 21-Dec-2011 Jesse Wilson <jessewilson@google.com> Don't reuse an SSL socket if the socket factory has changed.

Bug: http://b/3042192
Change-Id: Iaa9deb69058afcca4ab79ca6ba745c55d1e9321a
b2b02ac6cd42a69463fd172531aa1f9b9bb887a8 15-Dec-2011 Jesse Wilson <jessewilson@google.com> Change the way we cope with stale pooled connections.

Previously we'd attempt to detect if a connection was stale by
probing it. This was expensive (it relied on catching a 1-millisecond
read timing out with a SocketTimeoutException), and racy. If the
recycled connection was stale, the application would have to catch
the failure and retry.

The new approach is to try the stale connection directly and to recover
if that connection fails. This is simpler and avoids the isStale
heuristics.

This fixes some flakiness in URLConnectionTest tests like
testServerShutdownOutput and testServerClosesOutput.

Bug: http://b/2974888
Change-Id: I1f1711c0a6855f99e6ff9c348790740117c7ffb9
ed211506be4a0985678cf099282ed8fe851868fb 15-Aug-2011 Jesse Wilson <jessewilson@google.com> Make HTTP implementation details public for CTS tests.

Our testing tools cannot normally test package-private APIs
because the tests are loaded in a different class loader than
the production classes. This is an unfortunate workaround.

Change-Id: Ic8d9d3088887bccceaf166959468cd52bfef9aae
5292410e4ebf7fb5149eefd2f52fcb94c46690a6 24-May-2011 Jesse Wilson <jessewilson@google.com> Rewrite parsing for java.net.URL.

This fixes many broken cases on handling relative URLs.

We normalize all URLs by default. This will result
in more URL equality than before. Previously the URLs
http://android.com/a/../ and http://android.com/ were not
equal; now they are equal.

Change-Id: I8cf7be2e42eeb1386520be2698d8f14e0a55decb
http://b/4361656
cd8c1dd724036dcd1b7c27542cc4d745391b8d04 20-May-2011 Jesse Wilson <jessewilson@google.com> Support HTTP cookies and header combining.

Change-Id: Ifdf15dc2f551e58bdd6a1aae847f7dec254ac7e8
http://b/3180373
09f1b0cc860e039dff39e9429c1eaddcb6af598e 18-May-2011 Jesse Wilson <jessewilson@google.com> Parse HTTP request headers only once.

Change-Id: Ib3df045c546b424651eb1164c2dc610d366b5b39
7a891b5c83357dbeea2bbe4a5335ae685501e21c 18-May-2011 Jesse Wilson <jessewilson@google.com> Don't read through HTTP response headers more than necessary.

This refactoring changes HttpEngine to prefer the parsed
response headers over the raw response headers. I'll do likewise
for the request headers in a follow-up change.

Change-Id: Iab8329a836d14b3ac7bb0abe190e0a8fa7cc0694
396af46f45fd302e6309fc48ac1fd68cbb739edb 12-May-2011 Jesse Wilson <jessewilson@google.com> Add the application version to the DiskLruCache journal.

This makes it easy for us to change how we store HTTP cache
data without fear of compatibility problems.

Change-Id: I26cd6645d26f359ab76e2f87b6ab73bbf24ab715
http://b/3180373
ca8ae42fd6a787757897a680108bdcf7b0d37f13 12-May-2011 Jesse Wilson <jessewilson@google.com> Provide more user-friendly HTTP cache stats.

Rather than strictly trackign what's convenient for implementation,
we now provide stats based on what we anticipate the user will want
to know:
- how many requests were made?
- how many requests required network use?
- how many requests were served by the cache?

This doesn't provide individual stats on how many conditional gets
were made, but those can be computed.

Change-Id: Ieeebaf8b98664e78f828971052404dd7da28ad78
http://b/3180373
757afaa7afe96791a3cc612c9e3c4597a7321c7e 12-May-2011 Jesse Wilson <jessewilson@google.com> Provide hit and miss stats on the HTTP response cache.

Also capture FDs rather than InputStreams when a cache
entry is read. This permits the cache to return as many
streams as the caller requires.

Also fix bugs where we weren't properly releasing the
input streams from the responses.

Change-Id: I04807eab648864229f1e8734ad1fbb6a2d6bb51d
http://b/3180373
f589846f86761ffea3c06ab9d105d3f19328d121 11-May-2011 Jesse Wilson <jessewilson@google.com> Address code review comments to Adopt DiskLruCache change.

That change was submitted too early. This is the missing
follow-up.

Change-Id: I521455a7d249f8841c989561775c91d4368a8966
http://b/3180373
433e3fac172d0c4449051b0c61c0c63b298a0903 11-May-2011 Jesse Wilson <jessewilson@google.com> Adopt DiskLruCache in HttpResponseCache.

http://b/3180373

Change-Id: I55ed45c5d0b8fc72cf50e8912416367ac802dc7a
9531eea15052eccc004b5f853ab4452becf7a8ab 06-May-2011 Jesse Wilson <jessewilson@google.com> Test that headers aren't accidentally transferred across requests.

We used to have a bug where we'd only ever add headers. So if
a request was redirected from a.com to b.com to c.com, then
c.com would be able to see cookies from the other two hosts.

This was fixed by the HttpEngine refactor, but tests haven't
been added until now.

Change-Id: I01588fe9662aae7404fef4d4b2c4f0468e7c670d
http://b/3180373
c996149b500fc4825156106554457fe2394ae087 06-May-2011 Jesse Wilson <jessewilson@google.com> Fix proxy+HTTPS to handle authentication requests from the proxy.

Previously I'd introduced a bug by assuming that CONNECT
responses would always be successful.

Change-Id: Iaf0caf67f52154f6951a20284c75db0090843b99
http://b/4188137
19c77c6a6da8cea7327ccbb741963ac76d3fae53 05-May-2011 Jesse Wilson <jessewilson@google.com> Address some test failures in the HTTP client.

Change-Id: I44783aa7cadd51ed6b9e7aabc94144c60252c095
http://b/3180373
d742d7fc7f0593eb8c6e4ac9dd4c0f6a80374e46 05-May-2011 Jesse Wilson <jessewilson@google.com> Use GET after a POST is redirected.

Also dropping support for response code 305 Use Proxy, which
is seldom used, and whose behavior is quite different from
Chrome and Firefox. This is an intentional delta from the RI.

Also testing disconnect().

Change-Id: I80433f4776a2cfc5e228179421a787a44a4ded69
http://b/3180373
a4193d7e636802a2705ffb52cb69c69ff59bfbb2 05-May-2011 Jesse Wilson <jessewilson@google.com> Clean up HTTP engine connection reuse.

Also fixing cached responses to set warnings on the
response header and not the request header.

Change-Id: I4def2abf00e43aedc4baa63d1624bfa2f4d9bc16
953df613522e12a418cb7cb73248594d6c9f53d4 03-May-2011 Jesse Wilson <jessewilson@google.com> Refactor HttpURLConnection implementation.

Break HttpURLConnectionImpl into two parts: the part that
implements the Java API (that follows redirects etc.) and
the part that speaks HTTP. The HTTP part is called HttpEngine,
and it can only be used for a single HTTP request. This makes
it easier to set request properties that only apply to a
single socket request.

Tests for 'Vary', 'Content-Location' and warnings.

For simplicity of implementation I've chosen not to support
'Vary' at this time.

The 'Content-Location' header doesn't require any work from
the cache.

Warnings are ugly but allow the caller to identify when the
cache results may be problematic.

Also breaking HttpResponseCache's dependency on HttpURLConnectionImpl
so it can be tested on the RI.

Change-Id: Idbabb51251f479c2cdea4e0fceb029bfd07182be
http://b/3180373