@Override protected void encodeInitialLine(ByteBuf buf, HttpResponse response) throws Exception { response.protocolVersion().encode(buf); buf.writeByte(SP); response.status().encode(buf); ByteBufUtil.writeShortBE(buf, CRLF_SHORT); }
private void encodeChunkedContent(ChannelHandlerContext ctx, Object msg, long contentLength, List<Object> out) { if (contentLength > 0) { String lengthHex = Long.toHexString(contentLength); ByteBuf buf = ctx.alloc().buffer(lengthHex.length() + 2); buf.writeCharSequence(lengthHex, CharsetUtil.US_ASCII); ByteBufUtil.writeShortBE(buf, CRLF_SHORT); out.add(buf); out.add(encodeAndRetain(msg)); out.add(CRLF_BUF.duplicate()); } if (msg instanceof LastHttpContent) { HttpHeaders headers = ((LastHttpContent) msg).trailingHeaders(); if (headers.isEmpty()) { out.add(ZERO_CRLF_CRLF_BUF.duplicate()); } else { ByteBuf buf = ctx.alloc().buffer((int) trailersEncodedSizeAccumulator); ByteBufUtil.writeMediumBE(buf, ZERO_CRLF_MEDIUM); encodeHeaders(headers, buf); ByteBufUtil.writeShortBE(buf, CRLF_SHORT); trailersEncodedSizeAccumulator = TRAILERS_WEIGHT_NEW * padSizeForAccumulation(buf.readableBytes()) + TRAILERS_WEIGHT_HISTORICAL * trailersEncodedSizeAccumulator; out.add(buf); } } else if (contentLength == 0) { // Need to produce some output otherwise an // IllegalStateException will be thrown out.add(encodeAndRetain(msg)); } }
if (needSlash) { ByteBufUtil.writeShortBE(buf, SLASH_AND_SPACE_SHORT); } else { buf.writeByte(SP); ByteBufUtil.writeShortBE(buf, CRLF_SHORT);
req.command().encode(buffer); writeParameters(req.parameters(), buffer); ByteBufUtil.writeShortBE(buffer, CRLF_SHORT); out.add(buffer); release = false;
ByteBufUtil.writeShortBE(buf, CRLF_SHORT);
@Override protected void encodeInitialLine(final ByteBuf buf, final HttpMessage message) throws Exception { if (message instanceof HttpRequest) { HttpRequest request = (HttpRequest) message; ByteBufUtil.copy(request.method().asciiName(), buf); buf.writeByte(SP); buf.writeCharSequence(request.uri(), CharsetUtil.UTF_8); buf.writeByte(SP); buf.writeCharSequence(request.protocolVersion().toString(), CharsetUtil.US_ASCII); ByteBufUtil.writeShortBE(buf, CRLF_SHORT); } else if (message instanceof HttpResponse) { HttpResponse response = (HttpResponse) message; buf.writeCharSequence(response.protocolVersion().toString(), CharsetUtil.US_ASCII); buf.writeByte(SP); ByteBufUtil.copy(response.status().codeAsText(), buf); buf.writeByte(SP); buf.writeCharSequence(response.status().reasonPhrase(), CharsetUtil.US_ASCII); ByteBufUtil.writeShortBE(buf, CRLF_SHORT); } else { throw new UnsupportedMessageTypeException("Unsupported type " + StringUtil.simpleClassName(message)); } } }
@Override protected void encodeInitialLine(ByteBuf buf, HttpResponse response) throws Exception { response.protocolVersion().encode(buf); buf.writeByte(SP); response.status().encode(buf); ByteBufUtil.writeShortBE(buf, CRLF_SHORT); }
@Override protected void encodeInitialLine(ByteBuf buf, HttpResponse response) throws Exception { response.protocolVersion().encode(buf); buf.writeByte(SP); response.status().encode(buf); ByteBufUtil.writeShortBE(buf, CRLF_SHORT); }
@Override protected void encodeInitialLine(ByteBuf buf, HttpResponse response) throws Exception { response.protocolVersion().encode(buf); buf.writeByte(SP); response.status().encode(buf); ByteBufUtil.writeShortBE(buf, CRLF_SHORT); }
private void encodeChunkedContent(ChannelHandlerContext ctx, Object msg, long contentLength, List<Object> out) { if (contentLength > 0) { String lengthHex = Long.toHexString(contentLength); ByteBuf buf = ctx.alloc().buffer(lengthHex.length() + 2); buf.writeCharSequence(lengthHex, CharsetUtil.US_ASCII); ByteBufUtil.writeShortBE(buf, CRLF_SHORT); out.add(buf); out.add(encodeAndRetain(msg)); out.add(CRLF_BUF.duplicate()); } if (msg instanceof LastHttpContent) { HttpHeaders headers = ((LastHttpContent) msg).trailingHeaders(); if (headers.isEmpty()) { out.add(ZERO_CRLF_CRLF_BUF.duplicate()); } else { ByteBuf buf = ctx.alloc().buffer((int) trailersEncodedSizeAccumulator); ByteBufUtil.writeMediumBE(buf, ZERO_CRLF_MEDIUM); encodeHeaders(headers, buf); ByteBufUtil.writeShortBE(buf, CRLF_SHORT); trailersEncodedSizeAccumulator = TRAILERS_WEIGHT_NEW * padSizeForAccumulation(buf.readableBytes()) + TRAILERS_WEIGHT_HISTORICAL * trailersEncodedSizeAccumulator; out.add(buf); } } else if (contentLength == 0) { // Need to produce some output otherwise an // IllegalStateException will be thrown out.add(encodeAndRetain(msg)); } }
@Override protected void encodeInitialLine(ByteBuf buf, HttpResponse response) throws Exception { response.protocolVersion().encode(buf); buf.writeByte(SP); response.status().encode(buf); ByteBufUtil.writeShortBE(buf, CRLF_SHORT); }
private void encodeChunkedContent(ChannelHandlerContext ctx, Object msg, long contentLength, List<Object> out) { if (contentLength > 0) { String lengthHex = Long.toHexString(contentLength); ByteBuf buf = ctx.alloc().buffer(lengthHex.length() + 2); buf.writeCharSequence(lengthHex, CharsetUtil.US_ASCII); ByteBufUtil.writeShortBE(buf, CRLF_SHORT); out.add(buf); out.add(encodeAndRetain(msg)); out.add(CRLF_BUF.duplicate()); } if (msg instanceof LastHttpContent) { HttpHeaders headers = ((LastHttpContent) msg).trailingHeaders(); if (headers.isEmpty()) { out.add(ZERO_CRLF_CRLF_BUF.duplicate()); } else { ByteBuf buf = ctx.alloc().buffer((int) trailersEncodedSizeAccumulator); ByteBufUtil.writeMediumBE(buf, ZERO_CRLF_MEDIUM); encodeHeaders(headers, buf); ByteBufUtil.writeShortBE(buf, CRLF_SHORT); trailersEncodedSizeAccumulator = TRAILERS_WEIGHT_NEW * padSizeForAccumulation(buf.readableBytes()) + TRAILERS_WEIGHT_HISTORICAL * trailersEncodedSizeAccumulator; out.add(buf); } } else if (contentLength == 0) { // Need to produce some output otherwise an // IllegalStateException will be thrown out.add(encodeAndRetain(msg)); } }
private void encodeChunkedContent(ChannelHandlerContext ctx, Object msg, long contentLength, List<Object> out) { if (contentLength > 0) { String lengthHex = Long.toHexString(contentLength); ByteBuf buf = ctx.alloc().buffer(lengthHex.length() + 2); buf.writeCharSequence(lengthHex, CharsetUtil.US_ASCII); ByteBufUtil.writeShortBE(buf, CRLF_SHORT); out.add(buf); out.add(encodeAndRetain(msg)); out.add(CRLF_BUF.duplicate()); } if (msg instanceof LastHttpContent) { HttpHeaders headers = ((LastHttpContent) msg).trailingHeaders(); if (headers.isEmpty()) { out.add(ZERO_CRLF_CRLF_BUF.duplicate()); } else { ByteBuf buf = ctx.alloc().buffer((int) trailersEncodedSizeAccumulator); ByteBufUtil.writeMediumBE(buf, ZERO_CRLF_MEDIUM); encodeHeaders(headers, buf); ByteBufUtil.writeShortBE(buf, CRLF_SHORT); trailersEncodedSizeAccumulator = TRAILERS_WEIGHT_NEW * padSizeForAccumulation(buf.readableBytes()) + TRAILERS_WEIGHT_HISTORICAL * trailersEncodedSizeAccumulator; out.add(buf); } } else if (contentLength == 0) { // Need to produce some output otherwise an // IllegalStateException will be thrown out.add(encodeAndRetain(msg)); } }
private void encodeChunkedContent(ChannelHandlerContext ctx, Object msg, long contentLength, List<Object> out) { if (contentLength > 0) { String lengthHex = Long.toHexString(contentLength); ByteBuf buf = ctx.alloc().buffer(lengthHex.length() + 2); buf.writeCharSequence(lengthHex, CharsetUtil.US_ASCII); ByteBufUtil.writeShortBE(buf, CRLF_SHORT); out.add(buf); out.add(encodeAndRetain(msg)); out.add(CRLF_BUF.duplicate()); } if (msg instanceof LastHttpContent) { HttpHeaders headers = ((LastHttpContent) msg).trailingHeaders(); if (headers.isEmpty()) { out.add(ZERO_CRLF_CRLF_BUF.duplicate()); } else { ByteBuf buf = ctx.alloc().buffer((int) trailersEncodedSizeAccumulator); ByteBufUtil.writeMediumBE(buf, ZERO_CRLF_MEDIUM); encodeHeaders(headers, buf); ByteBufUtil.writeShortBE(buf, CRLF_SHORT); trailersEncodedSizeAccumulator = TRAILERS_WEIGHT_NEW * padSizeForAccumulation(buf.readableBytes()) + TRAILERS_WEIGHT_HISTORICAL * trailersEncodedSizeAccumulator; out.add(buf); } } else if (contentLength == 0) { // Need to produce some output otherwise an // IllegalStateException will be thrown out.add(encodeAndRetain(msg)); } }
if (needSlash) { ByteBufUtil.writeShortBE(buf, SLASH_AND_SPACE_SHORT); } else { buf.writeByte(SP); ByteBufUtil.writeShortBE(buf, CRLF_SHORT);
if (needSlash) { ByteBufUtil.writeShortBE(buf, SLASH_AND_SPACE_SHORT); } else { buf.writeByte(SP); ByteBufUtil.writeShortBE(buf, CRLF_SHORT);
@Override protected void encodeInitialLine(final ByteBuf buf, final HttpMessage message) throws Exception { if (message instanceof HttpRequest) { HttpRequest request = (HttpRequest) message; ByteBufUtil.copy(request.method().asciiName(), buf); buf.writeByte(SP); buf.writeCharSequence(request.uri(), CharsetUtil.UTF_8); buf.writeByte(SP); buf.writeCharSequence(request.protocolVersion().toString(), CharsetUtil.US_ASCII); ByteBufUtil.writeShortBE(buf, CRLF_SHORT); } else if (message instanceof HttpResponse) { HttpResponse response = (HttpResponse) message; buf.writeCharSequence(response.protocolVersion().toString(), CharsetUtil.US_ASCII); buf.writeByte(SP); ByteBufUtil.copy(response.status().codeAsText(), buf); buf.writeByte(SP); buf.writeCharSequence(response.status().reasonPhrase(), CharsetUtil.US_ASCII); ByteBufUtil.writeShortBE(buf, CRLF_SHORT); } else { throw new UnsupportedMessageTypeException("Unsupported type " + StringUtil.simpleClassName(message)); } } }
@Override protected void encodeInitialLine(final ByteBuf buf, final HttpMessage message) throws Exception { if (message instanceof HttpRequest) { HttpRequest request = (HttpRequest) message; ByteBufUtil.copy(request.method().asciiName(), buf); buf.writeByte(SP); buf.writeCharSequence(request.uri(), CharsetUtil.UTF_8); buf.writeByte(SP); buf.writeCharSequence(request.protocolVersion().toString(), CharsetUtil.US_ASCII); ByteBufUtil.writeShortBE(buf, CRLF_SHORT); } else if (message instanceof HttpResponse) { HttpResponse response = (HttpResponse) message; buf.writeCharSequence(response.protocolVersion().toString(), CharsetUtil.US_ASCII); buf.writeByte(SP); ByteBufUtil.copy(response.status().codeAsText(), buf); buf.writeByte(SP); buf.writeCharSequence(response.status().reasonPhrase(), CharsetUtil.US_ASCII); ByteBufUtil.writeShortBE(buf, CRLF_SHORT); } else { throw new UnsupportedMessageTypeException("Unsupported type " + StringUtil.simpleClassName(message)); } } }
@Override protected void encodeInitialLine(final ByteBuf buf, final HttpMessage message) throws Exception { if (message instanceof HttpRequest) { HttpRequest request = (HttpRequest) message; ByteBufUtil.copy(request.method().asciiName(), buf); buf.writeByte(SP); buf.writeCharSequence(request.uri(), CharsetUtil.UTF_8); buf.writeByte(SP); buf.writeCharSequence(request.protocolVersion().toString(), CharsetUtil.US_ASCII); ByteBufUtil.writeShortBE(buf, CRLF_SHORT); } else if (message instanceof HttpResponse) { HttpResponse response = (HttpResponse) message; buf.writeCharSequence(response.protocolVersion().toString(), CharsetUtil.US_ASCII); buf.writeByte(SP); ByteBufUtil.copy(response.status().codeAsText(), buf); buf.writeByte(SP); buf.writeCharSequence(response.status().reasonPhrase(), CharsetUtil.US_ASCII); ByteBufUtil.writeShortBE(buf, CRLF_SHORT); } else { throw new UnsupportedMessageTypeException("Unsupported type " + StringUtil.simpleClassName(message)); } } }
@Override protected void encodeInitialLine(final ByteBuf buf, final HttpMessage message) throws Exception { if (message instanceof HttpRequest) { HttpRequest request = (HttpRequest) message; ByteBufUtil.copy(request.method().asciiName(), buf); buf.writeByte(SP); buf.writeCharSequence(request.uri(), CharsetUtil.UTF_8); buf.writeByte(SP); buf.writeCharSequence(request.protocolVersion().toString(), CharsetUtil.US_ASCII); ByteBufUtil.writeShortBE(buf, CRLF_SHORT); } else if (message instanceof HttpResponse) { HttpResponse response = (HttpResponse) message; buf.writeCharSequence(response.protocolVersion().toString(), CharsetUtil.US_ASCII); buf.writeByte(SP); ByteBufUtil.copy(response.status().codeAsText(), buf); buf.writeByte(SP); buf.writeCharSequence(response.status().reasonPhrase(), CharsetUtil.US_ASCII); ByteBufUtil.writeShortBE(buf, CRLF_SHORT); } else { throw new UnsupportedMessageTypeException("Unsupported type " + StringUtil.simpleClassName(message)); } } }