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

41 Commits

Author SHA1 Message Date
jwilson
a27afaf572 Always prefer the server's returned response body.
Previously we would prefer the cached response if it had a newer
Last-Modified date.

Closes: https://github.com/square/okhttp/issues/2886
2016-11-14 20:52:43 -05:00
jwilson
d35436e12d Always use LinkedHashMap. Never HashMap. 2016-11-13 10:41:53 -05:00
Jake Wharton
749f4b960c WebSockets should show an empty body to interceptors. 2016-09-01 09:26:21 -04:00
Yuri Schimke
8fe73c05d8 java 9 tests 2016-07-03 07:03:48 -07:00
Jesse Wilson
8d51e740d7 Merge pull request #2666 from square/jwilson.0626.dead_code
Run IntelliJ's analysis on OkHttp.
2016-07-02 10:56:44 -04:00
Tobias Thierer
1ef0b078a8 Cleanup refactoring: Move 3 methods into DelegatingHttpsURLConnection
These three methods were delegating to delegate; their implementation
was duplicated across both subclasses of DelegatingHttpsURLConnection.

This change moves them into the base class in order to
  - avoid duplication
  - separate the responsibility of delegation (base class) from the
    responsibility of change to behavior (subclasses).

Notes:
 - Since these three methods are not available in Java 6, each of
   these need a @IgnoreJRERequirement annotation to pass the
   animal sniffer test. This appears like it should have been
   necessary before but for some reason it used to pass without.
 - This in turn requires a new dependency from okhttp-urlconnection
   onto animal-sniffer-annotations. The dependency was added onto
   version 1.11 of that library (consistent with okhttp itself);
   okio depends on version 1.10, the latest version is 1.15.
2016-06-28 18:22:02 -04:00
jwilson
a4d3082d2f Run IntelliJ's analysis on OkHttp.
This made a few hundred suggestions, many of which are thoughtful but
I'm deliberately ignoring anyway.

The following fixes are good ideas.
2016-06-27 00:47:50 -04:00
jwilson
c5187583bb Add connection, cache, and platform subpackages. 2016-06-26 23:04:30 -04:00
Jesse Wilson
89dc6d0c3d Merge pull request #2647 from square/jwilson.0621.dont_retry
Don't retry streamed HTTP request bodies.
2016-06-25 17:22:09 -04:00
jwilson
d8213e8156 Don't retry streamed HTTP request bodies. 2016-06-25 17:01:36 -04:00
jwilson
ec39c46232 Rename HttpURLConnectionImpl to OkHttpURLConnection.
This is an internal class so nobody should see the name. But having a
completely different name will make it much easier to diagnose future
stacktraces because the internal implementation has changed so much
recently.

Also share fewer internal details with the rest of OkHttp. In particular
remove the OkHttp-Selected-Protocol and OkHttp-Response-Source headers
from the core.
2016-06-25 15:46:24 -04:00
jwilson
084b06b48b Reimplement HttpURLConnection on the native OkHttp API. 2016-06-21 14:30:00 -04:00
Yuri Schimke
8ceb7480f3 tests running in JDK 9 2016-05-28 13:09:24 -04:00
jwilson
bab8943f2b Promote sent and received timestamps to fields on Response.
I'm currently keeping these as longs. That's easy an unambiguous, but it also
feels rather primitive.

This was more work than I expected, but it doesn't seem particularly risky.
It's also potentially more efficient, since there's fewer places where we're
converting from string to long and vice versa.

Closes: https://github.com/square/okhttp/issues/2035
2016-05-08 15:25:56 -04:00
Dave Roberge
8595234596 Handle 408 responses by retrying the request 2016-01-30 10:49:28 -05:00
jwilson
561613d579 Create request/response API tests to match some URLConnectionTest tests.
This is more work towards being able to later delete HttpURLConnectionImpl
without losing test coverage.

Also do some test cleanup.
2016-01-23 19:12:33 -05:00
Jake Wharton
ee83d8d26a Merge pull request #2185 from square/jwilson_0101_api_ergonomics
Detect API use errors earlier.
2016-01-02 02:13:16 -05:00
jwilson
7826bcb2fb Fix some get prefixes on Cache and ConnectionPool. 2016-01-02 02:07:30 -05:00
jwilson
d3675a5e0f Detect API use errors earlier.
Previously we would accept invalid input, but crash when that invalid input
was used.
2016-01-02 01:51:07 -05:00
jwilson
21d6303418 Restore no-args constructor for OkHttpClient.
This is a popular API and keeping it working is handy.
2016-01-01 15:22:14 -05:00
jwilson
38d570a6b2 Drop get and set prefixes in OkHttpClient, OkHttpClient.Builder 2016-01-01 12:12:35 -05:00
jwilson
f2461183e8 Refactor towards an OkHttpClient.Builder.
Still some work to do on method naming, but this was the interesting part.
Also very much need to rename OkUrlFactory in tests to urlFactory, otherwise
the client.client stuff becomes madness.
2016-01-01 10:55:32 -05:00
jwilson
32fb79996c Change CookieJar to deal with Cookies, not Headers.
There's a big consequence to this for compatible with RFC 2965 Cookies. In particular,
this drops our ability to support 'Set-Cookie2' headers, and some features used there
including quoted attributes like 'Max-Age="25"'. This is the right move for interop with
browsers, and likely to make things better for application developers, but some
people who strictly followed the RFC 2965 spec will be broken. (That spec was never
seriously adopted anywhere, which is the entire motivation of RFC 6265.)

The upside is the CookieJar interface is now much more straightforward. This is
particularly good going forward, and for clients who don't have to worry about the
strangeness of things like $Version=1 in the RFC 2965 spec.
2015-12-30 19:28:13 -05:00
jwilson
c9334bd90f New CookieJar interface.
No good first-party implementation yet.

There is an implementation in okhttp-urlconnection that delegates to the java.net
CookieHandler. That should be good enough for AOSP.
2015-12-24 14:19:37 -05:00
jwilson
98ae0fb92c Sort imports and wrap documentation at 100 columns.
This is a mechanical refactoring. The only thing I had trouble with is IntelliJ's
weak support for <ul> tags in Javadoc.
2015-12-23 19:34:28 -05:00
jwilson
9061a10ec5 Add TlsVersion to the Handshake.
This is awkward because it adds another field to the cache. I've
decided to try to keep old values in the cache working. We will
probably do a change that'll disrupt the cache later, but that
is invasive and we don't need that yet.
2015-12-21 23:02:31 -05:00
jwilson
c9a89876de Rename com.squareup.okhttp to okhttp3
Maven group changes will come in follow up.
2015-12-16 01:34:59 -05:00
jwilson
f9776c4adf Drop Request.uri(). Just use Request.url().uri().
There's a mostly-academic corner case on URLs like http://host/%xx that
have a malformed escape sequence. This changes the exceptions on those
URLs from checked to unchecked.

I think we may want a separate change to HttpUrl to fix those URLs to
be encoded as http://host/%25xx which avoids the problem altogether.

Closes: https://github.com/square/okhttp/issues/2106
2015-12-15 21:31:02 -05:00
Jake Wharton
dcb3c14435 Remove IOException from source() and streams. 2015-12-15 00:05:34 -05:00
jwilson
8e4394c022 Use the cipher suite enum rather than the string. 2015-12-14 19:24:00 -05:00
Jake Wharton
93d547dcda Make HttpUrl the blessed URL method of Request. 2015-12-14 15:11:48 -05:00
jwilson
68e3fbb0a3 Fix some breaks calling obsolete APIs. 2015-12-13 22:39:30 -05:00
jwilson
4c90a2e04a Use HttpUrl internally. 2015-08-02 21:01:26 -04:00
jwilson
a560f72193 Expose internal APIs for pluggable file systems.
We aren't yet ready to make FileSystem a public type, but I don't mind
making it _almost_ available via an internal API for those brave enough
to try that.

Also migrate all of our tests to use the in memory file system. It's simpler.

https://github.com/square/okhttp/issues/1459
2015-08-01 11:56:40 -07:00
Jake Wharton
8f5e344aba Fold MockWebServerRule into MockWebServer.
This avoid needing to duplicate the methods on the rule which historically was a subset of everything.

JUnit is now a required dependency.
2015-07-24 14:05:59 -04:00
Neil Fuller
b7baf23d86 Fix for issue #1589: Vary caching on Android
Keep the embedded OkHttp on Android working with Vary headers:

Vary headers were broken with android.net.http.HttpResponseCache:
the OkHttp caching requires a networkResponse to check the vary
headers and it was not being provided, leading to a
NullPointerException. Further changes were needed to actually
retain the request headers needed for the vary check itself.

Support for other stacks using the RequestCache has been
dropped for requests that include Vary headers.

To avoid regressions the existing ResponseCacheTest has been
changed to use the real cache. Previously, the use of
InMemoryResponseCache was hiding the Vary problem.

The ResponseCacheTest is now run with an AndroidShimResponseCache
to prove the tests work with real cases. The case without the shim
is covered with the CacheTest. ResponseCacheTest has been updated
to include many tests from CacheTest that were missing.

Switching the test to a real cache revealed a problem in the
JavaApiConverter and bad headers, which has been fixed by
making Headers.Builder.addLenient(String, String) accessible.
2015-04-30 16:00:28 +01:00
jwilson
1abba290f5 Never convert null into an empty request body.
This is a behavior change.
2015-04-16 19:53:13 -04:00
Neil Fuller
bb47389d85 Make badly-behaving caches cause a checked exception, not NPE
Android bug: https://code.google.com/p/android/issues/detail?id=160522
2015-03-23 15:25:21 +00:00
jwilson
4db679b39e Send at most one condition.
Related to https://github.com/square/okhttp/issues/831
Closes: https://github.com/square/okhttp/issues/1354
2015-01-30 17:29:57 -05:00
Neil Fuller
3a65dcd37b Fix ResponseCache handling for Android usecases
Including the code in
okhttp-android-support/src/test/java/com/squareup/okhttp/android
provides easy verification of API or behavior changes that might
affect Android.

There are some small JavaApiConverter improvements.
2015-01-14 13:43:46 +00:00
Neil Fuller
c9b0262c40 Create a new maven artifact to hold things needed for Android embedding
okhttp-android-support contains classes needed for Android embedding and
not for normal OkHttp development. The classes here can be excluded from
okhttp-urlconnection, shrinking that artifact. More classes will be
added to this component to make Android maintenance easier.
2015-01-12 10:55:17 +00:00