in http2-client/Sources/http2-client/main.swift [41:58]
func channelActive(context: ChannelHandlerContext) {
assert(context.channel.parent!.isActive)
var headers = HTTPHeaders(self.compoundRequest.headers)
headers.add(name: "host", value: self.host)
var reqHead = HTTPRequestHead(version: self.compoundRequest.version,
method: self.compoundRequest.method,
uri: self.compoundRequest.target)
reqHead.headers = headers
context.write(self.wrapOutboundOut(.head(reqHead)), promise: nil)
if let body = self.compoundRequest.body {
var buffer = context.channel.allocator.buffer(capacity: body.count)
buffer.writeBytes(body)
context.write(self.wrapOutboundOut(.body(.byteBuffer(buffer))), promise: nil)
}
context.writeAndFlush(self.wrapOutboundOut(.end(self.compoundRequest.trailers.map(HTTPHeaders.init))), promise: nil)
context.fireChannelActive()
}