okhttp icon indicating copy to clipboard operation
okhttp copied to clipboard

Add a socket abstraction

Open ean5533 opened this issue 9 months ago • 0 comments

What

This PR adds a bunch of abstractions over Socket and related factories. We named the abstraction classes things like OkioSocket which telegraphs our intent to eventually upstream these into Okio. For now they'll just live in okhttp3.internal.

Why

This is the first step toward making our test infrastructure better. This will allow us to create fake sockets that integrate with TaskFaker which yield on read/write so that other tasks can get a shot.

As a motivating use case, this will allow us to fix the flaky ConnectPoolTest.connectionPreWarmingHttp2.

What's next

  • Implement a bunch of fakes that play nicely with TaskFaker and use them in MockHttp2Peer, MockWebServer, etc
  • Maybe: Use composition instead of inheritance in OkioSslSocket

ean5533 avatar May 14 '24 18:05 ean5533