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

130 Commits

Author SHA1 Message Date
Jake Wharton
2c6be53791 Merge pull request #69 from square/jwilson/junit4
Unsuppress tests and upgrade to JUnit 4.
2012-12-29 13:38:32 -08:00
Jake Wharton
8b574cb48e Merge pull request #70 from square/jwilson/synch
Fix synchronization todos in SpdyStream.
2012-12-29 13:34:13 -08:00
jwilson
e4a4cbae4f Fix synchronization todos in SpdyStream.
This code had bugs where ongoing reads could prevent
writes from occurring. This update adds some asserts
to prevent synchronization errors.
2012-12-29 13:42:52 -07:00
jwilson
dca5d83027 Upgrade to JUnit 4.
Primary motivation is to gain access to @Ignore, for some
tests that haven't yet been written, or that don't work on
the RI (due to RI bugs).
2012-12-29 11:10:13 -07:00
jwilson
e3b90752dd Unsuppress some tests.
These were suppressed because they needed a bit of
work; I did that work and now they pass.
2012-12-27 23:15:42 -07:00
Jake Wharton
d10c20a7eb Merge pull request #67 from square/jwilson/libcore
Clean up utility code for submission to AOSP.
2012-12-26 15:08:40 -08:00
jwilson
67604f618d Clean up utility code for submission to AOSP.
This moves methods that will have Android-specific implementations
to Platform.java; all other utility methods are in a junk drawer
class called Utils.java.

This also moves method names (like "GET") to compare with .equals
instead of '=='. The old code took advantage of a hidden agreement
between HttpURLConnection and HttpEngine; with these in separate
projects that behavior isn't as obvious and shouldn't be relied
upon.
2012-12-26 11:31:25 -07:00
Jake Wharton
d2f4f21654 Merge pull request #66 from square/jwilson/new_apis
Promote Connection, ConnectionPool and Address APIs.
2012-12-23 21:47:29 -08:00
jwilson
78c6624b11 Promote Connection, ConnectionPool and Address APIs.
This moves HttpConnection.Address and HttpConnection.TunnelConfig
to their own top-level classes.
2012-12-24 00:39:48 -05:00
Jake Wharton
73291e89c4 Merge pull request #65 from square/jwilson/connection
Prepare to promote HttpConnection + Pool to public API.
2012-12-23 13:38:56 -08:00
jwilson
70e64037ff Prepare to promote HttpConnection + Pool to public API.
Giving the application code access to the connection pool
is tricky: it exposes more implementation details from
OkHttp; details that are quite inaccessible through the
conventional HttpURLConnection APIs. Currently the only
thing regular users get are a pair of awkward system
properties.

But exposing these should also be useful: it'll allow the
application to observe the pool (for performance monitoring)
and possibly also to directly manage it (by setting policy,
or to evict when the application is paused).
2012-12-22 18:05:27 -05:00
Jake Wharton
6579f9d974 Merge pull request #63 from square/jwilson/fewer_casts
Move the SSL socket factory and hostname verifier to the client.
2012-12-22 11:16:18 -08:00
Jake Wharton
ccb887c758 Merge pull request #64 from square/jwilson/tls_caching_tests
Restore tests for response caching + TLS.
2012-12-22 11:14:50 -08:00
jwilson
3d2547f188 Restore tests for response caching + TLS.
One of the test cases bitrotted to failure as a consequence
of the HTTP route selector change. I stopped assigning the
socket, which it needed to cache the TLS metadata. This is
fixed.
2012-12-22 13:40:29 -05:00
jwilson
7bcdc338d6 Move the SSL socket factory and hostname verifier to the client.
This saves clients from needing to cast to HttpsURLConnection
to expose the HTTPS-only accessors.
2012-12-22 12:43:27 -05:00
Jake Wharton
a7258910fa Merge pull request #61 from square/jwilson/fewer_statics
Move system-wide statics to the OkHttpClient class.
2012-12-21 19:52:57 -08:00
edenman
1ef490fe11 Merge pull request #62 from square/jwilson/commented_tests
Clean up commented out URLConnection tests.
2012-12-21 14:11:58 -08:00
jwilson
1c9cb2a0c2 Clean up commented out URLConnection tests.
There were some tests that only work on Dalvik/Linux: the CloseGuard
test and the timeout test rely on Linux-specific behavior that's too
flaky for a general test.

The TrustManager test just needed some attention and simplification to
work on both the JDK and Dalvik TLS stacks.
2012-12-21 16:28:13 -05:00
jwilson
1a1e1b7e2d Move system-wide statics to the OkHttpClient class.
This makes it possible to have two HttpClient instances that
don't share cookies or response cache policy. For example, a
program that makes both REST calls and downloads images may
prefer different response caches for each type of resource.
2012-12-21 11:39:24 -05:00
Jake Wharton
470c7f5986 Merge pull request #60 from square/jwilson/aosp
Prepare to use OkHttp to back HttpURLConnection in AOSP
2012-12-17 17:10:11 -08:00
jwilson
c9d183636d Bump the version number for backwards-incompatible changes. 2012-12-17 19:30:00 -05:00
jwilson
cb5a9a4ea3 Remove some dead code. 2012-12-15 17:09:11 -05:00
jwilson
50999cceb5 Move out of the libcore package.
To promote the code into AOSP, we'll keep this package as-is
and do the jarjar in Android instead.
2012-12-15 16:55:10 -05:00
jwilson
7f7aa90bc5 Switch to a builder for HttpURLConnection instances.
The builder has two upsides:
 - It allows us to use the same base classes from java.net
   as the base API.
 - It gives us a place to stash configuration in a place other
   than static fields. This will be useful for the connection
   pool, cookie manager, response cache, etc.
2012-12-15 16:17:18 -05:00
Patrick Forhan
3deadab31b Merge pull request #59 from square/jwilson/improve_reuse
Improve connection reuse.
2012-12-07 07:48:39 -08:00
Jesse Wilson
04d742bd3d Improve connection reuse.
Instead of trying to read the last bytes of a content body
when the input stream is read, do it when the connection is
closed. This approach is less elegant, since it requires
a connection to do work on behalf of a potentially nonexistent
follow up connection. But it should result in more reuse in
practice.

http://code.google.com/p/android/issues/detail?id=38817
2012-12-06 21:06:45 -05:00
Jake Wharton
f3d956e25b Merge pull request #58 from square/jwilson/checkstyle
Fix checkstyle issues.
2012-12-03 08:19:48 -08:00
Jesse Wilson
bbea4aaa6f Fix checkstyle issues. 2012-12-03 11:18:53 -05:00
Jake Wharton
8ab9438c70 Merge pull request #56 from square/jwilson/platform-api
New API to break platform-specific dependencies.
2012-11-14 00:31:39 -08:00
Jesse Wilson
9a1da9b420 New API to break platform-specific dependencies.
In particular:
 - Don't require OkHttp to depend on Jetty's non-boot package for
   Android. This was causing ugly, confidence-smashing dalvik
   errors in Android apps.
 - Don't prevent HTTP on Java6 just because SPDY isn't available.

This uses gross reflection and dynamic proxies! That's sad, but
it's encapsulated so users won't have to know it exists.
2012-11-13 23:12:12 -05:00
edenman
6991363c38 Merge pull request #55 from square/jwilson/npe-due-to-badhostname
Don't explode if DNS fails or if the address is malformed.
2012-11-12 12:39:02 -08:00
Jesse Wilson
084fa33870 Don't explode if DNS fails or if the address is malformed.
We had a bug where we were trying to report a proxy problem
before the connection was even created.
2012-11-12 12:34:05 -08:00
Jake Wharton
6af7cd22b3 Merge pull request #54 from square/jwilson/reconnect
Don't drop out of connect if the first request fails.
2012-11-11 12:53:55 -08:00
Jesse Wilson
51e5320e7b Don't drop out of connect if the first request fails.
This fixes a break caused by the recent try-harder-on-IP-addresses
change, where if the first connect failed we returned rather than
trying until we reached a connection or an error.
2012-11-11 12:45:50 -08:00
RayFromSquare
e8afabe11c Merge pull request #53 from square/jwilson/connection_selector
New route selector to support multiple routes.
2012-11-10 14:33:03 -08:00
Jesse Wilson
3355d0c99b New route selector to support multiple routes. 2012-11-10 13:05:53 -08:00
Jake Wharton
21e9c83988 Merge pull request #52 from square/jwilson/exercise
Fix some bugs from exercising HttpConnection + SPDY.
2012-11-07 14:20:59 -08:00
Jesse Wilson
e5b78cabad Fix some bugs from exercising HttpConnection + SPDY.
I was trying to reproduce a connectivity problem and
I found other related problems along the way:
 - We were unnecessarily creating new HttpConnection instances.
 - We were using "" as the file instead of "/" for SPDY.
2012-11-07 14:18:12 -08:00
Jake Wharton
e6aee71582 Merge pull request #49 from square/jwilson/connections
Make HttpConnection.connect return full working connections.
2012-11-05 21:42:42 -08:00
Jake Wharton
0ce37b70f8 Correct checkstyle errors. 2012-11-05 21:35:22 -08:00
Jesse Wilson
40ff765470 Make HttpConnection.connect return full working connections.
Previously the returned connections required the caller to
do extra work: setting up tunnels (which could require auth)
and performing an SSL handshake. With this change we make a
complete working connection in HttpConnection.connect().

This will make it easier to fix fallback when a single domain
has multiple IP addresses and some of those addresses are not
reachable.

This will also make it easier to do SPDY through HTTP proxies.
2012-11-05 20:25:52 -08:00
Jake Wharton
f1eacbff7e Merge pull request #48 from square/jwilson/recycle_gzip
Fix connection recycling for TLS+gzip+chunked.
2012-10-27 19:41:27 -07:00
Jesse Wilson
2f5e25e4dc Fix connection recycling for TLS+gzip+chunked.
We had a bug where the underlying SSLInputStream always returned
0 for InputStream.available(). This prevented us from ever reading
the "end of stream" chunk, which prevented connection recycling.
http://code.google.com/p/android/issues/detail?id=38817

Also fix a nearby bug where we were fast-forwarding the gzipped
stream when we should have been fast-forwarding the transfer
stream when we were preparing to recycle a connection.
2012-10-25 12:03:13 -04:00
Jake Wharton
4c39ccf9fe Merge pull request #47 from square/jwilson/tunnels
Fix a severe bug where multiple TLS tunnels were attempted.
2012-10-24 20:02:52 -07:00
Jesse Wilson
cbb33cbd05 Fix a severe bug where multiple TLS tunnels were attempted.
The previous code would attempt a TLS tunnel on reused
HTTPS connections, even after the tunnel had been established.
This is a severe protocol error!
2012-10-24 22:15:51 -04:00
Jake Wharton
51c7b6cad2 Write checkstyle to stdout. 2012-10-16 21:46:26 -07:00
Jake Wharton
b6e785e79e Merge pull request #46 from square/jwilson/close
Tests and code for various SPDY close scenarios.
2012-10-07 09:25:14 -07:00
Jake Wharton
df778b7b80 Switch to CONTRIBUTING file. 2012-10-05 22:43:59 -07:00
Jake Wharton
757f8ede89 Add Travis config. 2012-10-05 22:38:17 -07:00
Jesse Wilson
99fb988657 Tests and code for various SPDY close scenarios.
Writing this change has led me to believe that the
concurrency here is just plain awful, and I need to
find a better solution than what I have. In particular,
there are too many threads:
 - the internal reader thread
 - application reader threads
 - application writer threads
And too many locks:
 - the SpdyWriter I/O write lock
 - the SpdyConnection internal state lock
 - each SpdyStream's internal state lock

What's currently very wrong is the internal reader thread
is updating state in the SpdyStream, and reading bytes from
the network into a particular stream. It is an error to hold
the SpdyStream's lock while reading, but we're doing it because
we need to hold the state on the buffer, position and limit.
We need to rethink this!

Chrome doesn't run into this problem because it can 'fire and
forget' events. We can't do that because SPDY writes need to
throw IOExceptions if the writes fail.
2012-10-02 18:51:46 -04:00