Search in sources :

Example 11 with FullHttpRequest

use of com.couchbase.client.core.deps.io.netty.handler.codec.http.FullHttpRequest in project couchbase-jvm-clients by couchbase.

the class CoreHttpRequest method encode.

@Override
public FullHttpRequest encode() {
    FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, method, pathAndQueryString(), content);
    request.headers().add(headers);
    context().authenticator().authHttpRequest(serviceType(), request);
    return request;
}
Also used : FullHttpRequest(com.couchbase.client.core.deps.io.netty.handler.codec.http.FullHttpRequest) DefaultFullHttpRequest(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultFullHttpRequest) DefaultFullHttpRequest(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultFullHttpRequest)

Example 12 with FullHttpRequest

use of com.couchbase.client.core.deps.io.netty.handler.codec.http.FullHttpRequest in project couchbase-jvm-clients by couchbase.

the class QueryRequest 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());
    authenticator.authHttpRequest(serviceType(), request);
    return request;
}
Also used : FullHttpRequest(com.couchbase.client.core.deps.io.netty.handler.codec.http.FullHttpRequest) DefaultFullHttpRequest(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultFullHttpRequest) DefaultFullHttpRequest(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultFullHttpRequest) ByteBuf(com.couchbase.client.core.deps.io.netty.buffer.ByteBuf)

Example 13 with FullHttpRequest

use of com.couchbase.client.core.deps.io.netty.handler.codec.http.FullHttpRequest in project couchbase-jvm-clients by couchbase.

the class RawManagerIntegrationTest method canAddCustomHeader.

@Test
void canAddCustomHeader() {
    RawManagerRequest request = RawManagerRequest.get(ServiceType.MANAGER, "/pools");
    RawManagerOptions options = RawManagerOptions.rawManagerOptions().httpHeader("Accept", "text/html");
    Cluster clusterMock = mock(Cluster.class);
    Core core = mock(Core.class);
    when(clusterMock.environment()).thenReturn(cluster.environment());
    when(clusterMock.core()).thenReturn(core);
    when(core.context()).thenReturn(cluster.core().context());
    RawManager.call(clusterMock, request, options);
    ArgumentCaptor<GenericManagerRequest> captor = ArgumentCaptor.forClass(GenericManagerRequest.class);
    verify(core, times(1)).send(captor.capture());
    FullHttpRequest encoded = captor.getValue().encode();
    assertEquals(encoded.headers().get("Accept"), "text/html");
}
Also used : FullHttpRequest(com.couchbase.client.core.deps.io.netty.handler.codec.http.FullHttpRequest) GenericManagerRequest(com.couchbase.client.core.msg.manager.GenericManagerRequest) Cluster(com.couchbase.client.java.Cluster) Core(com.couchbase.client.core.Core) JavaIntegrationTest(com.couchbase.client.java.util.JavaIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 14 with FullHttpRequest

use of com.couchbase.client.core.deps.io.netty.handler.codec.http.FullHttpRequest in project couchbase-jvm-clients by couchbase.

the class BucketConfigRequest 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;
}
Also used : FullHttpRequest(com.couchbase.client.core.deps.io.netty.handler.codec.http.FullHttpRequest) DefaultFullHttpRequest(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultFullHttpRequest) DefaultFullHttpRequest(com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultFullHttpRequest)

Aggregations

FullHttpRequest (com.couchbase.client.core.deps.io.netty.handler.codec.http.FullHttpRequest)14 DefaultFullHttpRequest (com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultFullHttpRequest)7 ByteBuf (com.couchbase.client.core.deps.io.netty.buffer.ByteBuf)4 Test (org.junit.jupiter.api.Test)3 RequestTracer (com.couchbase.client.core.cnc.RequestTracer)2 ChannelClosedProactivelyEvent (com.couchbase.client.core.cnc.events.io.ChannelClosedProactivelyEvent)2 InvalidRequestDetectedEvent (com.couchbase.client.core.cnc.events.io.InvalidRequestDetectedEvent)2 FullHttpResponse (com.couchbase.client.core.deps.io.netty.handler.codec.http.FullHttpResponse)2 HttpResponse (com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpResponse)2 Response (com.couchbase.client.core.msg.Response)2 GenericManagerRequest (com.couchbase.client.core.msg.manager.GenericManagerRequest)2 Core (com.couchbase.client.core.Core)1 EmbeddedChannel (com.couchbase.client.core.deps.io.netty.channel.embedded.EmbeddedChannel)1 DefaultFullHttpResponse (com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultFullHttpResponse)1 DefaultHttpContent (com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultHttpContent)1 DefaultHttpResponse (com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultHttpResponse)1 DefaultLastHttpContent (com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultLastHttpContent)1 HttpContent (com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpContent)1 HttpMethod (com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpMethod)1 LastHttpContent (com.couchbase.client.core.deps.io.netty.handler.codec.http.LastHttpContent)1