1
0
mirror of https://github.com/square/okhttp.git synced 2026-01-27 04:22:07 +03:00
Commit Graph

16 Commits

Author SHA1 Message Date
Jesse Wilson
5d4e9ac850 Fix Authenticator callbacks to include full information.
These were passing the wrong parameters for proxies, and not
including enough information for origin servers.

Related to: http://code.google.com/p/android/issues/detail?id=18856
2012-09-20 20:33:00 -04:00
Jesse Wilson
b8c51dc5bd Fix a bug in tunnel construction and 'Connection: close' headers.
http://code.google.com/p/android/issues/detail?id=37221
2012-09-20 16:47:52 -04:00
Jesse Wilson
5aa2456a14 Fix TLS requiresTunnel which was being computed incorrectly.
We were only returning 'true' once we were already in a tunnel.
This was bogus. In theory a TLS tunnel sending extra data could
be corrupted due to this bug.

Also migrate one of the TLS tunnel tests to use SslContextBuilder
instead of TestSSLContext.
2012-09-20 16:01:17 -04:00
Jake Wharton
e60321991c Merge pull request #26 from square/jwilson/faster
Merge: Performance improvements: DiskLruCache, HttpResponseCache.
2012-09-19 14:28:55 -07:00
Jesse Wilson
761619286a Merge: Performance improvements: DiskLruCache, HttpResponseCache.
Original AOSP/libcore commit from Vladimir Marko:
Add StrictLineReader for efficient reading of lines
consistent with Streams.readAsciiLine(). Use this to improve
DiskLruCache.readJournal() and initialization of
HttpResponseCache$Entry from InputStream.

(cherry-pick of e03b551079aae1204e505f1dc24f2b986ef82ec0.)

Bug: 6739304
Change-Id: If3083031f1368a9bbbd405c91553d7a205fd4e39
2012-09-19 17:18:48 -04:00
Jake Wharton
51a46a4db6 Merge pull request #25 from square/jwilson/cache504
Merge: HttpResponseCache should return 504, not 502.
2012-09-19 14:17:47 -07:00
Jesse Wilson
8d06f68600 Merge: HttpResponseCache should return 504, not 502.
Original AOSP/libcore commit from Elliott Hughes:
The RFC seems pretty clear on this issue.

Bug: http://code.google.com/p/android/issues/detail?id=28294
Change-Id: Ia9a979e1fbbd8b38b1607059c042e0fc9ca44270
2012-09-19 16:48:48 -04:00
Jesse Wilson
1594066552 Merge: Fix HttpURLConnection CloseGuard warning due to lack of close on GZIPInputStream
Original AOSP/libcore commit by Brian Carlstrom:
java.lang.Throwable: Explicit termination method 'end' not called
  at dalvik.system.CloseGuard.open(CloseGuard.java:184)
  at java.util.zip.Inflater.<init>(Inflater.java:82)
  at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:96)
  at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:81)
  at libcore.net.http.HttpEngine.initContentStream(HttpEngine.java:523)
  at libcore.net.http.HttpEngine.readResponse(HttpEngine.java:831)
  at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:274)
  at libcore.net.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:486)
  at ...

Bug: 6602529
Change-Id: I9b49cbca561f8780d08844e566820087fdffc4d7
2012-09-19 16:23:53 -04:00
Jesse Wilson
1bc9e2ef26 Merge: Tolerate cache files being removed from underneath DiskLruCache
Original AOSP/libcore commit by Brian Carlstrom:
Bug: 6777079
Change-Id: I2f950ab6d847dd63061aeb449fc5d46ab9e6c50a
2012-09-19 16:09:34 -04:00
Jesse Wilson
85e568e52d Merge: HttpEngine should not attempt to cache proxy CONNECT responses
Original AOSP/libcore commit from Brian Carlstrom:
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
2012-09-19 15:33:48 -04:00
Jesse Wilson
43a332bca4 Fail gracefully on a 401 response code with no WWW-Authenticate header.
This is more lenient than necessary; the HTTP spec says this:
  10.4.2 401 Unauthorized
     The request requires user authentication. The response MUST include a
     WWW-Authenticate header field (section 14.47) containing a challenge
     applicable to the requested resource.

Not throwing will still cause the request to fail, since the 401
response code triggers an IOException. But this type of failure is
more recoverable and allows the caller to inspect the headers and
response body.
2012-08-15 15:55:48 -04:00
Jesse Wilson
66220f81e3 Support Froyo.
This makes a bunch of sad changes for compatibility:
 - Using String.length() rather than String.isEmpty()
 - Using String.getBytes(String) rather than String.getBytes(Charset)
 - Using new String(..., String) rather than new String(..., Charset)
 - Avoiding TimeUnit.DAYS

I've tested this and the HTTP tests run perfectly fine on Froyo.
The HTTPS tests time out due to a bug in Froyo that prevents
its TLS library from working as a server. I manually verified
that TLS works as a client without problem.

I also tested this on Gingerbread. It passes all tests except
for testConnectViaHttpProxyToHttpsUsingProxySystemProperty, which
fails because of a bug in Gingerbread's java.net.ProxySelector.

This change introduces caching reflective objects for NPN access.
That'll make clients that make multiple SSL connections slightly
more efficient.
2012-08-01 20:09:14 -04:00
Jesse Wilson
3ff6ca140d Uncomment more HTTPS tests.
Also:
 - bump mockwebserver to current.
 - create a uniform API for creating connections
2012-08-01 14:41:29 -04:00
Jesse Wilson
33a0c620e1 Use bouncy castle to generate certs for TLS.
Because there are no platform APIs to generate certificates,
this needs a third party library (bouncy castle) to do the
heavy lifting.

Each target platform has its own built-in crypto library:
 - The JVM has its own internal crypto library. It uses
   key stores like "JCA".
 - Android has its own internal crypto library that's
   based on bouncy castle. It is repackaged in com.android
   and is not used by this code.

With this change, okhttp brings its own copy of bouncy castle
for cert generation. Once the certificate is generated we're
done with bouncy castle, and use the platform libraries for TLS.
This approach allows us to use one codebase on either platform.
2012-08-01 12:50:04 -04:00
Jesse Wilson
4425f3ec2b Don't connect to external hosts in unit tests. 2012-07-23 12:20:21 -04:00
Jesse Wilson
ea63463c2f Initial import.
This is a fork of okhttp from http://code.google.com/p/okhttp.
I'm moving it to Github since that's where my code reviewers
are. I've renamed the core package from com.google.okhttp to
com.squareup.okhttp because Square is where I expect ongoing
development of this project to take place.

All code in this project is subject to be contributed upstream
to AOSP. In particular, all code in the libcore package is
derived from AOSP and intended to be contributed back to AOSP
on an ongoing basis.
2012-07-23 10:02:28 -04:00