All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vertx.rxjava.core.http.HttpClientBuilder Maven / Gradle / Ivy

There is a newer version: 5.0.0.CR2
Show newest version
/*
 * Copyright 2014 Red Hat, Inc.
 *
 * Red Hat licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package io.vertx.rxjava.core.http;

import rx.Observable;
import rx.Single;
import io.vertx.rx.java.RxHelper;
import io.vertx.rx.java.WriteStreamSubscriber;
import io.vertx.rx.java.SingleOnSubscribeAdapter;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.Iterator;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import io.vertx.core.Handler;
import io.vertx.core.AsyncResult;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import io.vertx.lang.rx.RxGen;
import io.vertx.lang.rx.TypeArg;
import io.vertx.lang.rx.MappingIterator;

/**
 * A builder for {@link io.vertx.rxjava.core.http.HttpClient}.
 *
 * 

* NOTE: This class has been automatically generated from the {@link io.vertx.core.http.HttpClientBuilder original} non RX-ified interface using Vert.x codegen. */ @RxGen(io.vertx.core.http.HttpClientBuilder.class) public class HttpClientBuilder { @Override public String toString() { return delegate.toString(); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; HttpClientBuilder that = (HttpClientBuilder) o; return delegate.equals(that.delegate); } @Override public int hashCode() { return delegate.hashCode(); } public static final TypeArg __TYPE_ARG = new TypeArg<>( obj -> new HttpClientBuilder((io.vertx.core.http.HttpClientBuilder) obj), HttpClientBuilder::getDelegate ); private final io.vertx.core.http.HttpClientBuilder delegate; public HttpClientBuilder(io.vertx.core.http.HttpClientBuilder delegate) { this.delegate = delegate; } public HttpClientBuilder(Object delegate) { this.delegate = (io.vertx.core.http.HttpClientBuilder)delegate; } public io.vertx.core.http.HttpClientBuilder getDelegate() { return delegate; } /** * Configure the client options. * @param options the client options * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.core.http.HttpClientBuilder with(io.vertx.core.http.HttpClientOptions options) { delegate.with(options); return this; } /** * Configure the client with the given pool options. * @param options the pool options * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.core.http.HttpClientBuilder with(io.vertx.core.http.PoolOptions options) { delegate.with(options); return this; } /** * Set a connection handler for the client. This handler is called when a new connection is established. * @param handler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.core.http.HttpClientBuilder withConnectHandler(io.vertx.core.Handler handler) { delegate.withConnectHandler(new io.vertx.lang.rx.DelegatingHandler<>(handler, event -> io.vertx.rxjava.core.http.HttpConnection.newInstance((io.vertx.core.http.HttpConnection)event))); return this; } /** * Set a redirect handler for the http client. *

* The redirect handler is called when a 3xx response is received and the request is configured to * follow redirects with {@link io.vertx.rxjava.core.http.HttpClientRequest#setFollowRedirects}. *

* The redirect handler is passed the {@link io.vertx.rxjava.core.http.HttpClientResponse}, it can return an {@link io.vertx.rxjava.core.http.HttpClientRequest} or null. *

    *
  • when null is returned, the original response is processed by the original request response handler
  • *
  • when a new Future is returned, the client will send this new request
  • *
* The new request will get a copy of the previous request headers unless headers are set. In this case, * the client assumes that the redirect handler exclusively managers the headers of the new request. *

* The handler must return a Future unsent so the client can further configure it and send it. * @param handler the new redirect handler * @return a reference to this, so the API can be used fluently */ public io.vertx.rxjava.core.http.HttpClientBuilder withRedirectHandler(java.util.function.Function> handler) { delegate.withRedirectHandler(new Function>() { public io.vertx.core.Future apply(io.vertx.core.http.HttpClientResponse arg) { io.vertx.core.Future ret = handler.apply(io.vertx.rxjava.core.http.HttpClientResponse.newInstance((io.vertx.core.http.HttpClientResponse)arg)); return ret.map(val -> val); } }); return this; } /** * Build and return the client. * @return the client as configured by this builder */ public io.vertx.rxjava.core.http.HttpClientAgent build() { io.vertx.rxjava.core.http.HttpClientAgent ret = io.vertx.rxjava.core.http.HttpClientAgent.newInstance((io.vertx.core.http.HttpClientAgent)delegate.build()); return ret; } /** * Configure the client to use a specific address resolver. * @param resolver the address resolver * @return */ public io.vertx.rxjava.core.http.HttpClientBuilder withAddressResolver(io.vertx.core.net.AddressResolver resolver) { io.vertx.rxjava.core.http.HttpClientBuilder ret = io.vertx.rxjava.core.http.HttpClientBuilder.newInstance((io.vertx.core.http.HttpClientBuilder)delegate.withAddressResolver(resolver)); return ret; } /** * Configure the client to use a load balancer. * @param loadBalancer the load balancer * @return */ public io.vertx.rxjava.core.http.HttpClientBuilder withLoadBalancer(io.vertx.core.net.endpoint.LoadBalancer loadBalancer) { io.vertx.rxjava.core.http.HttpClientBuilder ret = io.vertx.rxjava.core.http.HttpClientBuilder.newInstance((io.vertx.core.http.HttpClientBuilder)delegate.withLoadBalancer(loadBalancer)); return ret; } public static HttpClientBuilder newInstance(io.vertx.core.http.HttpClientBuilder arg) { return arg != null ? new HttpClientBuilder(arg) : null; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy