1
0
mirror of https://github.com/square/okhttp.git synced 2025-11-23 06:42:24 +03:00
Commit Graph

168 Commits

Author SHA1 Message Date
Yuri Schimke
362f53546d Adopt Version Catalog and Updates plugin (#7075) 2022-02-15 23:38:32 +00:00
Jesse Wilson
699a2122fc Move code from RealConnection to RealConnectPlan (#7065)
* Move code from RealConnection to RealConnectPlan

Also promote RealConnectPlan to a top-level type, ConnectPlan.

Each RealConnection is now created only once its ready to be used
to carry exchanges. We do the actual connect work in ConnectPlan.

* Move startHttp2() back to RealConnection

* Update FastFallbackExchangeFinder for split RealConnection
2022-02-09 20:25:37 -05:00
Goooler
f5758b7f26 Enable Gradle's type-safe project accessors (#7069) 2022-02-08 20:01:28 +00:00
Jesse Wilson
8f9222cd69 Tests for FastFallbackExchangeFinder (#7047)
* Tests for FastFallbackExchangeFinder

This needed more test facets in TaskFaker.

I'm pretty happy with how the tests read.

* More tests for FastFallbackExchangeFinder.
2022-02-01 16:14:44 -05:00
Jesse Wilson
19939f6707 Reorder IP addresses for Fast Fallback (#7048)
* Reorder IP addresses for Fast Fallback

* Shut down TaskFaker after each test

It now owns an ExecutorService that should be shut down.
2022-02-01 11:51:33 -05:00
Jesse Wilson
1a2245a1a6 Rewrite TaskFaker to permit mutiple stalled tasks (#7046)
In order to deterministically test FastFallbackExchangeFinder I need
a test facet that supports several test coordinating:
 - the call thread is waiting for either a connection to connect
   or for the next-connection timeout (250 ms) to elapse
 - the in-flight connection needs to connect

TaskFaker wasn't up to the task for this because it assumed at most
two threads, the test thread and the task thread.

With this change TaskFaker can coordinate multiple task threads
that each run sequentially, as directed by a test thread.
2022-01-31 15:46:51 -05:00
Jesse Wilson
f15c81b4e9 HappyEyeballs (#7035)
This doesn't yet introduce any mechanism to enable or disable
happy eyeballs.

It also doesn't sort IP addresses to alternate IPv6, IPv4
for best success.

It also doesn't limit how many connections are attempted
simultaneously.

It also lacks an appropriate number of tests.
2022-01-28 11:11:05 -05:00
Jesse Wilson
d4b5c9eac8 Create TestValueFactory to reduce test case boilerplate (#7038)
This is bad because it moves test logic out of tests. But it's also
good because it lowers the cost of writing unit tests with common
types like RealConnection and Route.
2022-01-28 07:35:27 -05:00
Jesse Wilson
35bb1740a4 Convert the main build.gradle file to KTS (#6925)
I attempted to do a literal translation as much as possible.
Subprojects now need plugins to be configured directly so they
can use the appropriate syntax.
2021-11-24 07:19:39 +00:00
Yuri Schimke
c1a6dec505 Allow Custom SSLSocketFactory without ALPN support (#6862)
* Allow Custom SSLSocketFactory without ALPN support

* Allow Custom SSLSocketFactory without ALPN support

* Revert reformatting

* Reuse delegate classes
2021-11-23 20:29:18 -05:00
Jesse Wilson
1ed9863131 Upgrade to Okio 3.0.0 (#6896) 2021-10-29 10:39:56 +03:00
Goooler
e1af67f082 Declare types & Cleanup (#6842)
* Declare types

* Code cleanup

* Declare types
2021-08-30 23:32:43 -04:00
Goooler
f54b300ece Convert SAM (#6828) 2021-08-28 13:38:04 +01:00
Goooler
cc3ce11fc4 Code cleanup and imports (#6822) 2021-08-03 14:52:10 +03:00
Goooler
619c3256e7 Convert native-image gradle to kts (#6798) 2021-07-31 09:35:08 +03:00
Yuri Schimke
71427d373b Fix OpenJSSE build (#6657) 2021-06-01 18:08:51 +10:00
Yuri Schimke
f62173afbb Add debug helper for JSSE Handshakes (#6579) 2021-04-03 05:22:56 +01:00
Yuri Schimke
6901b9c1d3 Repro for channel hang and with TLS extensions disabled (#6554) 2021-02-14 09:10:59 +00:00
Yuri Schimke
b607bb0aa8 Partial move to gradle kotlin (#6532) 2021-02-06 14:57:47 +00:00
Yuri Schimke
6e8aa12dd6 Okio Filesystem (#6500)
* Testing okio

* Working tests

* Working tests

* Working tests

* Working tests

* okio 3

* Fix dependencies

* File system

* Cleanup

* Cleanup

* Cleanup

* Cache fixes

* Cache fixes

* Review comments

* Cleanup

* Cleanup

* Build fixes
2021-02-06 08:49:05 -05:00
Yuri Schimke
1808173038 Support Android in Connection Spec Tests (#6435) 2020-11-25 08:46:00 +00:00
Yuri Schimke
a334f6f14f Fix single failing graal test (#6445) 2020-11-22 12:12:58 -05:00
Jesse Wilson
2f361c245f Don't assert about suppressed exceptions in GraalVM (#6441) 2020-11-22 00:35:23 -05:00
Yuri Schimke
ec1d18d143 Quick Android Test Fixes (#6428) 2020-11-21 09:50:01 +00:00
Yuri Schimke
4036fa55b7 Update remaining junit4 tests (#6421) 2020-11-14 12:21:04 -05:00
Yuri Schimke
daac9be139 Fix Android tests post junit 5 (#6408) 2020-11-14 07:12:48 +00:00
Yuri Schimke
b1ee602958 Fix for native image and assumptions (#6414) 2020-11-12 22:09:53 -05:00
Yuri Schimke
998633be00 Assert on effective cipher suite order (#6410) 2020-11-11 07:01:59 +00:00
Yuri Schimke
81b1b14a56 Use clean assumptions APIs (#6405) 2020-11-08 15:14:50 +00:00
Yuri Schimke
0d5a9cecb3 Workaround native image params issue (#6401) 2020-11-08 07:30:54 +00:00
Yuri Schimke
4677beea96 Add more n-i-t tests from okhttp (#6387) 2020-11-03 19:56:29 +00:00
Jesse Wilson
59ae0c138d Convert more tests to JUnit 5 (#6366) 2020-11-01 05:46:35 +00:00
Jesse Wilson
963c768643 Migrate all OkHttpClientTestRule uses to JUnit 5 (#6365) 2020-10-31 18:51:34 -04:00
Jesse Wilson
f8065acac2 Execute CallTest with JUnit 5 (#6349)
* Execute CallTest with JUnit 5
* Avoid Optional.isEmpty which is JDK11+
2020-10-30 06:59:02 +00:00
Yuri Schimke
ec221f36af Cache Corruption Test (#6287)
Working test but a base for cache expectations with corruptions and deliberate failure cases.
2020-10-02 08:24:24 +01:00
Yuri Schimke
a76c40a935 Kotlin 1.4 dependency upgrade and language features (#5947) 2020-09-06 16:36:12 +01:00
Yuri Schimke
15b7d47185 JSSE Debug in tests (#6041) 2020-05-17 18:10:09 +01:00
Yuri Schimke
198900de0b Fix isAndroid check (#6055)
Fix for OkHttp platform issues in AndroidStudio (e.g. when running as a plugin)

square/retrofit#3389
2020-05-16 09:09:46 +01:00
Yuri Schimke
fea8fbba5f Attempt to minimise WebSocket test flakiness (#6045) 2020-05-13 07:46:19 +01:00
Yuri Schimke
4bd93ad176 Rethrow original failure in OkHttpClientTestRule (#6037) 2020-05-09 17:12:34 +01:00
Yuri Schimke
8cebf9012b Cache Events (#6015)
Provide EventListener methods to understand the impact of caching.
2020-05-05 18:25:06 +01:00
Yuri Schimke
af1eadfebf Record Http2 Frames and TaskRunner optionally for Flaky tests (#6011) 2020-05-03 20:21:12 +01:00
Jesse Wilson
3ca806c24b Don't crash processing fragmented web sockets messages (#5983)
* Don't crash processing fragmented web sockets messages

Closes: https://github.com/square/okhttp/issues/5965

* Update okhttp-testing-support/src/main/kotlin/okhttp3/TestUtil.kt

Co-Authored-By: Jake Wharton <jakew@google.com>

* Update okhttp-testing-support/src/main/kotlin/okhttp3/TestUtil.kt

Co-Authored-By: Jake Wharton <jakew@google.com>

* Update okhttp-testing-support/src/main/kotlin/okhttp3/TestUtil.kt

Co-Authored-By: Jake Wharton <jakew@google.com>

Co-authored-by: Jake Wharton <jakew@google.com>
2020-04-23 23:31:36 -04:00
Jesse Wilson
64d3b079f2 Fix DiskLruCache to work on Windows
As originally designed DiskLruCache assumes an inode-like
file system, where it's fine to delete files that are
currently being read or written.

On Windows the file system forbids this, so we must be
more careful when deleting and renaming files. These
operations come up a lot internally in the cache:
 - deleting to evict an entry
 - renaming to commit a dirty file to a clean file

The workaround is simple if unsatisfying: we don't
permit concurrent reads and writes on Windows. We
can have multiple concurrent reders, or a single
writer.

One challenge in this implementation is detecting
whether we're running on Windows or a good operating
system. We deliberately don't look at System properties
here because the OS and file system may disagree, such
as when a Windows machine has an ext4 partition, or when
a Linux machine has an NTFS partition. Instead of detecting
we just attempt an edit and see what happens.

Another challenge in this implementation is what to
do when a file needs to be deleted but cannot be because
it is currently open. In such cases we now mark the
cache entry as a 'zombie'. When the files are later
closed they now check for zombie status and delete the
files if necessary. Note that it is not possible to
store a new cache entry while it is a zombie.

Closes: https://github.com/square/okhttp/issues/5761
2020-04-11 20:16:40 -04:00
Yuri Schimke
86b7ba5f2a Enable BouncyCastle on Android and add some testing (#5936) 2020-04-11 17:35:27 +01:00
Yuri Schimke
19771365f2 Rename to src/main/kotlin (#5938)
Follows the default path logic for kotlin classes.
2020-04-11 17:15:25 +01:00
Jesse Wilson
ac53284db4 Emulate Windows file system restrictions in a wrapper
This should make it possible to get DiskLruCacheTest passing on
Windows even when Windows isn't available.
2020-04-11 11:12:56 -04:00
Yuri Schimke
b3b788a942 Upgrade to Android 10 APIs when available (#5821)
* Upgrade robolectric dependency

* cleanup

* Suppress animal sniffer checks on known classes

* Update build.gradle

* Update build.gradle
2020-04-10 10:42:29 -04:00
Yuri Schimke
b48d30aa5c Move okhttp-testing-support to Kotlin (#5906)
Moving the last big block of src/main Java code (outside of Samples).
2020-04-09 07:23:43 +01:00
Yuri Schimke
e8cfef759f Force cancel all events on client (#5901) 2020-03-26 06:45:34 +00:00