* Decompose the request line into individual properties
Replace the 'path' property with the URL's encodedPath
property.
Rename the 'requestUrl' property to 'url'.
* Spotless
* Fix up DnsOverHttpsTest
* Fix some test failures
* Fix a liveness bug in MockWebServer
It was possible to configure delays that would be honored
after MockWebServer was shut down. With this fix any
delay will be abandoned once the server is closed.
* Update mockwebserver/src/main/kotlin/mockwebserver3/internal/SleepNanos.kt
Co-authored-by: Jake Wharton <jw@squareup.com>
---------
Co-authored-by: Jesse Wilson <jwilson@squareup.com>
Co-authored-by: Jake Wharton <jw@squareup.com>
Also remove @ExperimentalOkHttpApi in a few places.
Also rename 'shutdown' to 'close' in MockWebServer
and Dispatcher.
Also rename QueueDispatcher.enqueueResponse() to
QueueDispatcher.enqueue.
Co-authored-by: Jesse Wilson <jwilson@squareup.com>
* Change MockWebServer to use Okio's new Socket interface
This replaces the Stream interface introduced in a recent
alpha release.
* apiDump
* Only buffer once
---------
Co-authored-by: Jesse Wilson <jwilson@squareup.com>
On Request.Builder the one function can add the header
and apply compression. Otherwise the caller needs to
keep those calls in sync.
One severe drawback of this approach is the calls to
Request.Builder are now ordered. If you call gzip()
before you call post(), it'll crash. Worse, if you
call post() and then gzip() and then post() again
with a different body, it'll silently not compress
the new body. I don't love this drawback but I think
the mitigations aren't worth the effort.
* Finalize the new API for MockResponse
It's a value object with a bunch of fields, and a builder.
* Tunnel then body
---------
Co-authored-by: Jesse Wilson <jwilson@squareup.com>
* TrailersSource, a new public API for HTTP trailers
This doesn't change much.
The new interface replaces a Kotlin lambda that had
similar behavior, though that lambda wasn't specified
as thoroughly.
We now permit calls to Response.trailers() before the
entire response body is consumed. But when such calls are
made the response body is discarded first. This could be
a bit of a surprise to users, especially users who do an
additional layer of buffering over their ResponseBody
because it could yield latent failures.
But I think it's better behavior overall, especially since
it's possible data binding layers might not consume the
entire response body in all cases. For example, a JSON
library might not read to the very end of the response
if it has received a terminating '}' byte.
The riskiest part of this change is when ResponseBodySource
self-reports as complete. Previously it would self-report
as complete when it returned as many bytes as promised
in the Content-Length. With this change it will now only
report itself complete when it receives a definitive EOF
on the stream, signaled by a -1 byte count on a read. This
is because only when the EOF is received can we be sure
that the trailers are received, and we must not unhook
the Exchange from the Call until that happens. The previous
behavior could make Call.cancel() no-op even if we were
blocked waiting on trailers.
* apiDump
* Attempt to get more tests passing
* Don't wait for stream EOF to release the stream
One of our tests caught a situation where we were waiting
for the caller to read the EOF when we didn't need to.
---------
Co-authored-by: Jesse Wilson <jwilson@squareup.com>
I'd like to update the API to improve observability into things
like ConnecitonPool, RoutePlanner, ConnectPlan, and ReusePlan.
And also into HTTP/2 internals like flow-control.
As-is this is more coupled to Call lifecycles and is somewhat
duplicative with ConnectionPool.
We'll do that work and make it a new public API, but we won't
have it in the public API at all for the 5.0 release.
Co-authored-by: Jesse Wilson <jwilson@squareup.com>
* Run the loom tests on JDK 24
I recently broke support for Loom on earlier JDKs
* Install JDK24
---------
Co-authored-by: Jesse Wilson <jwilson@squareup.com>
* Fix test execution on Robolectric
We had a regression in 5.0.0-alpha.15 that broke test execution
on Robolectric. Now that works again.
Closes: https://github.com/square/okhttp/issues/8821
* Spotless
---------
Co-authored-by: Jesse Wilson <jwilson@squareup.com>
The Dispatcher class is an outlier here as it cannot implement
the Lockable interface without that leaking into its public API.
We do without in that case.
Co-authored-by: Jesse Wilson <jwilson@squareup.com>
* Change the locking mechanism to 'synchronized'
We migrated to ReentrantReadWriteLock to better support Loom,
but now we can use synchronized and still support Loom.
This old mechanism may be faster than ReentrantReadWriteLock.
* Update okhttp/src/commonJvmAndroid/kotlin/okhttp3/internal/concurrent/Lockable.kt
Co-authored-by: Yuri Schimke <yuri@schimke.ee>
---------
Co-authored-by: Jesse Wilson <jesse@swank.ca>
Co-authored-by: Yuri Schimke <yuri@schimke.ee>
* Upgrade Okio to 3.12.0
* Start using BufferedSource.indexOf() with a toIndex
This avoids the need for the new FixedLengthSource class.
---------
Co-authored-by: Jesse Wilson <jwilson@squareup.com>
* Stop double-compressing the PublicSuffixDatabase
It's compressed as a .gz file that's also in a .jar file.
Previously the compressed size was 42,502 bytes, and the
total okhttp.jar file was 884,193.
With this change, the total okhttp.jar file is 884,154 bytes.
* PR feedback
* Spotless
* Fix native image tests' build
They need friendsImplementation to test internal APIs
* Also fix the package name
---------
Co-authored-by: Jesse Wilson <jwilson@squareup.com>
* Inline RequestCommon
This is an artifact of our multiplatform exploration.
* Fixup null tags
* Spotless
---------
Co-authored-by: Jesse Wilson <jwilson@squareup.com>
* Split EventListener.retryDecision into retryDecision and followUpDecision
retryDecision has an exception, and is related to
connectivity failures.
followUpDecision has an intermediate response, and is
related to redirects and auth challenges.
This drops the reason strings, which have 'logging brain'
and I want to push our users towards 'metrics brain'.
* Spotless
* apiDump
* Fix another test
---------
Co-authored-by: Jesse Wilson <jwilson@squareup.com>