Java Code Examples for io.netty.handler.codec.http2.Http2Headers#setInt()
The following examples show how to use
io.netty.handler.codec.http2.Http2Headers#setInt() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Http2Handler.java From xrpc with Apache License 2.0 | 6 votes |
/** * Writes the given response body as "text/plain" to the given stream. Marks the response status * metric. Closes the stream after writing the response. */ private void writeResponse( ChannelHandlerContext ctx, int streamId, HttpResponseStatus status, ByteBuf body) { Preconditions.checkArgument(body != null, "body must not be null"); markResponseStatus(ctx, status); Http2Headers headers = new DefaultHttp2Headers(true); // TODO(jkinkead): This should honor accept headers; we shouldn't send text/plain if the client // doesn't want it. headers.set(CONTENT_TYPE, "text/plain"); headers.setInt(CONTENT_LENGTH, body.readableBytes()); headers.status(status.codeAsText()); writeResponse(ctx, streamId, headers, Optional.of(body)); }
Example 2
Source File: ArmeriaHttpUtilTest.java From armeria with Apache License 2.0 | 5 votes |
@Test void endOfStreamSet() { final Http2Headers in = new DefaultHttp2Headers(); in.setInt(HttpHeaderNames.CONTENT_LENGTH, 0); final HttpHeaders out = toArmeria(in, true, true); assertThat(out.isEndOfStream()).isTrue(); final HttpHeaders out2 = toArmeria(in, true, false); assertThat(out2.isEndOfStream()).isFalse(); }