Search in sources :

Example 1 with HttpMethod

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

the class CoreAnalyticsLinkManager method sendLink.

private CompletableFuture<Void> sendLink(HttpMethod method, Map<String, String> link, CoreCommonOptions options, String tracingId) {
    // ensure mutability, and don't modify caller's map
    link = new HashMap<>(link);
    CoreHttpPath path = getLinkPathAndAdjustMap(link);
    UrlQueryStringBuilder form = newForm();
    link.forEach(form::set);
    return httpClient.newRequest(method, path, options).trace(tracingId).form(form).exec(core).exceptionally(t -> {
        throw translateCompilationFailureToInvalidArgument(t);
    }).thenApply(result -> null);
}
Also used : Builder.newForm(com.couchbase.client.core.endpoint.http.CoreHttpRequest.Builder.newForm) AnalyticsErrorContext(com.couchbase.client.core.error.context.AnalyticsErrorContext) HttpMethod(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpMethod) UrlQueryStringBuilder(com.couchbase.client.core.util.UrlQueryStringBuilder) CoreHttpClient(com.couchbase.client.core.endpoint.http.CoreHttpClient) CouchbaseException(com.couchbase.client.core.error.CouchbaseException) RequestTarget(com.couchbase.client.core.msg.RequestTarget) CompilationFailureException(com.couchbase.client.core.error.CompilationFailureException) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) InvalidArgumentException(com.couchbase.client.core.error.InvalidArgumentException) CoreHttpPath(com.couchbase.client.core.endpoint.http.CoreHttpPath) CoreCommonOptions(com.couchbase.client.core.endpoint.http.CoreCommonOptions) CbCollections.mapOf(com.couchbase.client.core.util.CbCollections.mapOf) TracingIdentifiers(com.couchbase.client.core.cnc.TracingIdentifiers) CoreHttpResponse(com.couchbase.client.core.endpoint.http.CoreHttpResponse) Map(java.util.Map) CoreHttpPath.path(com.couchbase.client.core.endpoint.http.CoreHttpPath.path) Builder.newQueryString(com.couchbase.client.core.endpoint.http.CoreHttpRequest.Builder.newQueryString) Objects.requireNonNull(java.util.Objects.requireNonNull) Stability(com.couchbase.client.core.annotation.Stability) CbThrowables(com.couchbase.client.core.util.CbThrowables) Core(com.couchbase.client.core.Core) CoreHttpPath(com.couchbase.client.core.endpoint.http.CoreHttpPath) UrlQueryStringBuilder(com.couchbase.client.core.util.UrlQueryStringBuilder)

Example 2 with HttpMethod

use of com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpMethod 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;
}
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) HttpMethod(com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpMethod)

Aggregations

HttpMethod (com.couchbase.client.core.deps.io.netty.handler.codec.http.HttpMethod)2 Core (com.couchbase.client.core.Core)1 Stability (com.couchbase.client.core.annotation.Stability)1 TracingIdentifiers (com.couchbase.client.core.cnc.TracingIdentifiers)1 ByteBuf (com.couchbase.client.core.deps.io.netty.buffer.ByteBuf)1 DefaultFullHttpRequest (com.couchbase.client.core.deps.io.netty.handler.codec.http.DefaultFullHttpRequest)1 FullHttpRequest (com.couchbase.client.core.deps.io.netty.handler.codec.http.FullHttpRequest)1 CoreCommonOptions (com.couchbase.client.core.endpoint.http.CoreCommonOptions)1 CoreHttpClient (com.couchbase.client.core.endpoint.http.CoreHttpClient)1 CoreHttpPath (com.couchbase.client.core.endpoint.http.CoreHttpPath)1 CoreHttpPath.path (com.couchbase.client.core.endpoint.http.CoreHttpPath.path)1 Builder.newForm (com.couchbase.client.core.endpoint.http.CoreHttpRequest.Builder.newForm)1 Builder.newQueryString (com.couchbase.client.core.endpoint.http.CoreHttpRequest.Builder.newQueryString)1 CoreHttpResponse (com.couchbase.client.core.endpoint.http.CoreHttpResponse)1 CompilationFailureException (com.couchbase.client.core.error.CompilationFailureException)1 CouchbaseException (com.couchbase.client.core.error.CouchbaseException)1 InvalidArgumentException (com.couchbase.client.core.error.InvalidArgumentException)1 AnalyticsErrorContext (com.couchbase.client.core.error.context.AnalyticsErrorContext)1 RequestTarget (com.couchbase.client.core.msg.RequestTarget)1 CbCollections.mapOf (com.couchbase.client.core.util.CbCollections.mapOf)1