use of io.servicetalk.http.api.HttpMetaData in project servicetalk by apple.
the class HttpResponseDecoderTest method smuggleBeforeNonZeroContentLengthHeader.
@Test
void smuggleBeforeNonZeroContentLengthHeader() {
int contentLength = 128;
writeMsg(startLineForContent() + "\r\n" + "Host: servicetalk.io" + "\r\n" + // [1] https://tools.ietf.org/html/rfc7230#section-3.3.3
"Smuggled: " + startLine() + "\r\n\r\n" + "Content-Length: " + contentLength + "\r\n" + "Connection: keep-alive" + "\r\n\r\n");
HttpMetaData metaData = assertStartLineForContent();
assertSingleHeaderValue(metaData.headers(), HOST, "servicetalk.io");
assertSingleHeaderValue(metaData.headers(), "Smuggled", startLine());
Buffer buffer = channel().readInbound();
assertThat(buffer.toString(US_ASCII), is("Content-Length: " + contentLength + "\r\nConnection: keep-alive\r\n\r\n"));
channel().close();
assertEmptyTrailers(channel());
assertFalse(channel().finishAndReleaseAll());
}
use of io.servicetalk.http.api.HttpMetaData in project servicetalk by apple.
the class HttpResponseDecoderTest method smuggleBeforeTransferEncodingHeader.
@Test
void smuggleBeforeTransferEncodingHeader() {
writeMsg(startLineForContent() + "\r\n" + "Host: servicetalk.io" + "\r\n" + // [1] https://tools.ietf.org/html/rfc7230#section-3.3.3
"Smuggled: " + startLine() + "\r\n\r\n" + TRANSFER_ENCODING + ": " + CHUNKED + "\r\n" + "Connection: keep-alive" + "\r\n\r\n");
HttpMetaData metaData = assertStartLineForContent();
assertSingleHeaderValue(metaData.headers(), HOST, "servicetalk.io");
assertSingleHeaderValue(metaData.headers(), "Smuggled", startLine());
Buffer buffer = channel().readInbound();
assertThat(buffer.toString(US_ASCII), is(TRANSFER_ENCODING + ": " + CHUNKED + "\r\nConnection: keep-alive\r\n\r\n"));
channel().close();
assertEmptyTrailers(channel());
assertFalse(channel().finishAndReleaseAll());
}
use of io.servicetalk.http.api.HttpMetaData in project servicetalk by apple.
the class HttpObjectDecoderTest method chunkedWithContentLength.
private void chunkedWithContentLength(boolean crlf) {
EmbeddedChannel channel = channel(crlf);
String br = br(crlf);
int chunkSize = 128;
int chunkedContentLength = 2 + 2 + chunkSize + 2 + 5;
writeMsg(startLineForContent() + br + "Host: servicetalk.io" + br + "Connection: keep-alive" + br + "Content-Length: " + chunkedContentLength + br + "Transfer-Encoding: chunked" + br + br, channel);
writeChunk(chunkSize, channel);
writeLastChunk(channel);
HttpMetaData metaData = validateWithContent(-chunkSize, false, channel);
assertThat("Unexpected content-length header(s)", metaData.headers().valuesIterator(CONTENT_LENGTH).hasNext(), is(false));
}
use of io.servicetalk.http.api.HttpMetaData in project servicetalk by apple.
the class HttpObjectDecoderTest method testHeaderFiledValue.
private void testHeaderFiledValue(String fieldValue, String expectedFieldValue, boolean crlf) {
EmbeddedChannel channel = channel(crlf);
String br = br(crlf);
writeMsg(startLine() + br + "Host:" + fieldValue + br + br, channel);
HttpMetaData metaData = assertStartLine(channel);
assertSingleHeaderValue(metaData.headers(), HOST, expectedFieldValue);
assertEmptyTrailers(channel);
}
use of io.servicetalk.http.api.HttpMetaData in project servicetalk by apple.
the class HttpObjectDecoderTest method chunkedNoContentNoTrailers.
private void chunkedNoContentNoTrailers(boolean crlf) {
EmbeddedChannel channel = channel(crlf);
String br = br(crlf);
writeMsg(startLineForContent() + br + "Host: servicetalk.io" + br + "Connection: keep-alive" + br + "Transfer-Encoding: chunked" + br + br, channel);
writeLastChunk(channel);
HttpMetaData metaData = assertStartLineForContent(channel);
assertStandardHeaders(metaData.headers());
assertEmptyTrailers(channel);
assertFalse(channel.finishAndReleaseAll());
}
Aggregations