use of com.couchbase.client.core.deps.io.netty.handler.codec.http.FullHttpRequest in project couchbase-jvm-clients by couchbase.
the class NonChunkedHttpMessageHandlerTest method callsMarkRequestCompletedOnceFinished.
@Test
void callsMarkRequestCompletedOnceFinished() throws Exception {
channel.pipeline().addFirst(NonChunkedHttpMessageHandler.IDENTIFIER, new TestNonChunkedHttpMessageHandler(endpoint));
channel.pipeline().fireChannelActive();
CoreHttpRequest request = CoreHttpRequest.builder(CoreCommonOptions.of(Duration.ofSeconds(1), BestEffortRetryStrategy.INSTANCE, null), endpoint.context(), HttpMethod.GET, CoreHttpPath.path("/"), RequestTarget.views("bucket")).build();
channel.writeAndFlush(request);
FullHttpRequest written = channel.readOutbound();
assertEquals("/", written.uri());
FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
channel.writeInbound(response);
assertEquals(ResponseStatus.SUCCESS, request.response().get().status());
verify(endpoint, times(1)).markRequestCompletion();
}
use of com.couchbase.client.core.deps.io.netty.handler.codec.http.FullHttpRequest in project couchbase-jvm-clients by couchbase.
the class ViewRequest method encode.
@Override
public FullHttpRequest encode() {
StringBuilder path = new StringBuilder();
path.append("/").append(bucket).append("/_design/");
path.append(development ? "dev_" + design : design);
path.append("/_view/");
path.append(view);
path.append("?").append(query);
ByteBuf content = keysJson.isPresent() ? Unpooled.copiedBuffer(keysJson.get()) : Unpooled.EMPTY_BUFFER;
HttpMethod method = keysJson.isPresent() ? HttpMethod.POST : HttpMethod.GET;
FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, method, path.toString(), content);
request.headers().set(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.APPLICATION_JSON).set(HttpHeaderNames.CONTENT_LENGTH, content.readableBytes()).set(HttpHeaderNames.USER_AGENT, context().environment().userAgent().formattedLong());
authenticator.authHttpRequest(serviceType(), request);
return request;
}
use of com.couchbase.client.core.deps.io.netty.handler.codec.http.FullHttpRequest in project couchbase-jvm-clients by couchbase.
the class BucketConfigStreamingRequest method encode.
@Override
public FullHttpRequest encode() {
FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, String.format(PATH, bucketName));
authenticator.authHttpRequest(serviceType(), request);
return request;
}
use of com.couchbase.client.core.deps.io.netty.handler.codec.http.FullHttpRequest in project couchbase-jvm-clients by couchbase.
the class GenericManagerRequest method encode.
@Override
public FullHttpRequest encode() {
FullHttpRequest request = requestSupplier.get();
context().authenticator().authHttpRequest(serviceType(), request);
return request;
}
use of com.couchbase.client.core.deps.io.netty.handler.codec.http.FullHttpRequest in project couchbase-jvm-clients by couchbase.
the class AnalyticsRequest method encode.
@Override
public FullHttpRequest encode() {
ByteBuf content = Unpooled.wrappedBuffer(query);
FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, URI, content);
request.headers().set(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.APPLICATION_JSON);
request.headers().set(HttpHeaderNames.CONTENT_LENGTH, content.readableBytes());
request.headers().set(HttpHeaderNames.USER_AGENT, context().environment().userAgent().formattedLong());
if (priority != NO_PRIORITY) {
request.headers().set("Analytics-Priority", priority);
}
authenticator.authHttpRequest(serviceType(), request);
return request;
}
Aggregations