Pull #1011 broke ResponseCacheTest on Android.
The test was asserting a header generated
using a copy of the old broken implementation.
The test now just uses HttpDate, which now has its own
tests.
Ensuring that this Android bug is fixed for the next
Android release:
https://code.google.com/p/android/issues/detail?id=66135
On Android the SimpleDateFormat for "zzz" returns GMT+00:00.
This is regrettable but awkward to change as it is existing
behavior.
https://code.google.com/p/android/issues/detail?id=66136
This change fixes the format to 'GMT'.
This change also fixes a bug where the platform default
timezone was used for parsing some date/times and not GMT.
Various tests have been added to prove the behavior when
timezones are missing and dates are malformed.
An HTTP client interacts with the network in two main ways: DNS
lookups and connections to HTTP servers. OkHttp already abstracts
the latter by allowing callers to pass in custom SocketFactory
objects, but does not yet abstract the former.
This change takes the existing internal Dns interface, which is
currently used for testing, and turns it into a publicly
accessible HostResolver interface. This allows callers to
completely abstract all network interaction points.
Examples of what this can be used for:
1. Use alternative DNS implementations with different
performance / caching / ordering / parallelization / ...
characteristics than standard InetAddress.getAllByName.
2. Resolve hosts using different DNS servers than the system
resolvers, or even non-DNS protocols (e.g., MDNS or even
NetBIOS/WINS) that are not supported by the system resolver.
3. Do DNS lookups on specific networks, similarly to what
android_getaddrinfofornet does.
Change-Id: I6e488acd938067e4c078c6ffe4d5eddb5f3951de
Currently, the passed-in socket factory is only used for
connections to HTTP proxies. I think this was not the intent of
the original socket factory change, because the commit message
said that the "socket factory will be used for all non-proxy
connections and HTTP proxy connections". So use it for DIRECT
connections as well.
Also add a test to check that a socket factory is used if
specified.
Change-Id: I811b08442d1c80be1a0a268eb51c9aa365febf00
The HttpEngine would not obey the set state because there was no
correlation between the HttpURLConnection.setInstanceFollowRedirects
method and the OkHttpClient.
Fixed the missing link by adding a new setFollowRedirects method to the
OkHttpClient class. Bridged the gap for the HttpURLConnection.setInstanceFollowRedirects
by forwarding that state into the OkHttpClient.
Now the HttpEngine will always obey the OkHttpClient redirect state when
attempting the followUp phase.
Added necessary test to both OkUrlFactoryTest and CallTest.
https://github.com/square/okhttp/issues/943
Through the various code paths that an Entry would pass through both the clean and dirty File would be needed at least once. Creating it and the StringBuilders every time was having a large impact on allocation in high-frequency situations (like images in an Android app).