Scoop API

scoop:scoop.http.client:0.1.0

src/transport/http2.scoop

Selected production source · src/transport/http2.scoop

1package scoop.http.client
3import scoop.http.*
4import scoop.http.asyncio.AsyncHttp2Stream
5import scoop.platform.memory.NativeByteBuffer
7internal class ClientH2Exchange(val call: ClientCall, val stream: AsyncHttp2Stream) : ClientExchange {
8 public override val version: HttpVersion get() = HttpVersion.Http2
9 public override val isReadComplete: Boolean get() = stream.isReadComplete
10 public override val trailers: Array<HttpField>? get() = stream.trailers
11 public override suspend fun receiveResponse(): HttpResponseHead = try { stream.receiveResponse() }
12 catch (error: Throwable) { recordClientIoFailure(call, error, true); throw error }
13 finally { if (clientPresent(call.observation)) observeClientFirstByte(call, stream.firstResponseByteAt); Unit }
14 public override suspend fun readInto(buffer: NativeByteBuffer, count: Long): Long = try { stream.readInto(buffer, count) }
15 catch (error: Throwable) { recordClientIoFailure(call, error, true); throw error }
16 public override suspend fun writeFrom(buffer: NativeByteBuffer, count: Long): Long = stream.writeFrom(buffer, count)
17 public override suspend fun flush() { stream.flush() }
18 public override suspend fun finish(trailers: List<HttpField>) { stream.finish(trailers) }
19 public override suspend fun close() { stream.close() }