forked from square/okhttp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Public API for duplex streams in MockWebServer (square#7595)
* Public API for duplex streams in MockWebServer I'm not 100% on the name 'Stream' for the source+sink pair. It's tempting to use 'Socket', though I think that's an implementation name and this is an abstraction that uses a different implementation. I've chosen Stream specifically 'cause it's the word used in the HTTP/2 spec. My biggest gripe with it is that it's bidirectional in the HTTP/2 spec, but Java InputStream and OutputStream are not bidirectional. * Dump APIs for streams * Don't include a Content-Length header for chunked bodies * Convert MockWebServerTest to Kotlin (square#7596) * Rename .java to .kt * Convert Java to Kotlin * Null isn't special for last-write wins * Attempt to make NonCompletingRequestBody less flaky
- Loading branch information
1 parent
c30d3ce
commit 34bb125
Showing
14 changed files
with
1,000 additions
and
938 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (C) 2022 Block, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package mockwebserver3 | ||
|
||
import okio.BufferedSink | ||
import okio.BufferedSource | ||
|
||
/** | ||
* A bidirectional sequence of data frames exchanged between client and server. | ||
*/ | ||
interface Stream { | ||
val requestBody: BufferedSource | ||
val responseBody: BufferedSink | ||
|
||
/** | ||
* Terminate the stream so that no further data is transmitted or received. Note that | ||
* [requestBody] may return data after this call; that is the buffered data received before this | ||
* stream was canceled. | ||
* | ||
* This does nothing if [requestBody] and [responseBody] are already closed. | ||
* | ||
* For HTTP/2 this sends the [CANCEL](https://datatracker.ietf.org/doc/html/rfc7540#section-7) | ||
* error code. | ||
*/ | ||
fun cancel() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.