use of io.servicetalk.http.api.HttpRequestMetaData in project servicetalk by apple.
the class HttpRequestEncoderTest method contentLengthNoTrailers.
@Test
void contentLengthNoTrailers() {
EmbeddedChannel channel = newEmbeddedChannel();
byte[] content = new byte[128];
ThreadLocalRandom.current().nextBytes(content);
Buffer buffer = allocator.wrap(content);
HttpRequestMetaData request = newRequestMetaData(HTTP_1_1, GET, "/some/path?foo=bar&baz=yyy", INSTANCE.newHeaders());
request.headers().add(CONNECTION, KEEP_ALIVE).add(USER_AGENT, "unit-test").add(CONTENT_LENGTH, valueOf(content.length));
channel.writeOutbound(request);
channel.writeOutbound(buffer.duplicate());
channel.writeOutbound(EmptyHttpHeaders.INSTANCE);
verifyHttpRequest(channel, buffer, TransferEncoding.ContentLength, false);
consumeEmptyBufferFromTrailers(channel);
assertFalse(channel.finishAndReleaseAll());
}
use of io.servicetalk.http.api.HttpRequestMetaData in project servicetalk by apple.
the class HttpRequestEncoderTest method contentLengthNoTrailersHeaderWhiteSpaceThrowByDefault.
@Test
void contentLengthNoTrailersHeaderWhiteSpaceThrowByDefault() {
EmbeddedChannel channel = newEmbeddedChannel();
HttpRequestMetaData request = newRequestMetaData(HTTP_1_1, GET, "/some/path?foo=bar&baz=yyy", INSTANCE.newHeaders());
assertThrows(IllegalArgumentException.class, () -> request.addHeader(" " + CONNECTION, KEEP_ALIVE));
assertFalse(channel.finishAndReleaseAll());
}
use of io.servicetalk.http.api.HttpRequestMetaData in project servicetalk by apple.
the class HttpRequestEncoderTest method chunkedNoTrailersNoContent.
@Test
void chunkedNoTrailersNoContent() {
EmbeddedChannel channel = newEmbeddedChannel();
HttpRequestMetaData request = newRequestMetaData(HTTP_1_1, GET, "/some/path?foo=bar&baz=yyy", INSTANCE.newHeaders());
request.headers().add(CONNECTION, KEEP_ALIVE).add(USER_AGENT, "unit-test").add(TRANSFER_ENCODING, CHUNKED);
channel.writeOutbound(request);
channel.writeOutbound(EMPTY_BUFFER.duplicate());
channel.writeOutbound(EmptyHttpHeaders.INSTANCE);
verifyHttpRequest(channel, EMPTY_BUFFER, TransferEncoding.Chunked, false);
assertFalse(channel.finishAndReleaseAll());
}
use of io.servicetalk.http.api.HttpRequestMetaData in project servicetalk by apple.
the class HttpRequestEncoderTest method chunkedWithTrailers.
@Test
void chunkedWithTrailers() {
EmbeddedChannel channel = newEmbeddedChannel();
byte[] content = new byte[128];
ThreadLocalRandom.current().nextBytes(content);
Buffer buffer = allocator.wrap(content);
HttpHeaders trailers = INSTANCE.newTrailers();
trailers.add("TrailerStatus", "good");
HttpRequestMetaData request = newRequestMetaData(HTTP_1_1, GET, "/some/path?foo=bar&baz=yyy", INSTANCE.newHeaders());
request.headers().add(CONNECTION, KEEP_ALIVE).add(USER_AGENT, "unit-test").add(TRANSFER_ENCODING, CHUNKED);
channel.writeOutbound(request);
channel.writeOutbound(buffer.duplicate());
channel.writeOutbound(trailers);
verifyHttpRequest(channel, buffer, TransferEncoding.Chunked, true);
assertFalse(channel.finishAndReleaseAll());
}
use of io.servicetalk.http.api.HttpRequestMetaData in project servicetalk by apple.
the class HttpRequestEncoderTest method chunkedNoTrailers.
@Test
void chunkedNoTrailers() {
EmbeddedChannel channel = newEmbeddedChannel();
byte[] content = new byte[128];
ThreadLocalRandom.current().nextBytes(content);
Buffer buffer = allocator.wrap(content);
HttpRequestMetaData request = newRequestMetaData(HTTP_1_1, GET, "/some/path?foo=bar&baz=yyy", INSTANCE.newHeaders());
request.headers().add(CONNECTION, KEEP_ALIVE).add(USER_AGENT, "unit-test").add(TRANSFER_ENCODING, CHUNKED);
channel.writeOutbound(request);
channel.writeOutbound(buffer.duplicate());
channel.writeOutbound(EmptyHttpHeaders.INSTANCE);
verifyHttpRequest(channel, buffer, TransferEncoding.Chunked, false);
assertFalse(channel.finishAndReleaseAll());
}
Aggregations