Ejemplo n.º 1
0
 private void prepareHeaders() {
   HttpHeaders headers = request.headers();
   headers.remove(TRANSFER_ENCODING);
   if (!headers.contains(HOST)) {
     request.headers().set(HOST, conn.hostHeader());
   }
   if (chunked) {
     HttpHeaders.setTransferEncodingChunked(request);
   }
   if (client.getOptions().isTryUseCompression()
       && request.headers().get(ACCEPT_ENCODING) == null) {
     // if compression should be used but nothing is specified by the user support deflate and
     // gzip.
     request.headers().set(ACCEPT_ENCODING, DEFLATE_GZIP);
   }
   if (!client.getOptions().isKeepAlive()
       && client.getOptions().getProtocolVersion() == io.vertx.core.http.HttpVersion.HTTP_1_1) {
     request.headers().set(CONNECTION, CLOSE);
   } else if (client.getOptions().isKeepAlive()
       && client.getOptions().getProtocolVersion() == io.vertx.core.http.HttpVersion.HTTP_1_0) {
     request.headers().set(CONNECTION, KEEP_ALIVE);
   }
 }
Ejemplo n.º 2
0
 @Override
 public HttpClientRequestImpl setChunked(boolean chunked) {
   synchronized (getLock()) {
     checkComplete();
     if (written > 0) {
       throw new IllegalStateException(
           "Cannot set chunked after data has been written on request");
     }
     // HTTP 1.0 does not support chunking so we ignore this if HTTP 1.0
     if (client.getOptions().getProtocolVersion() != io.vertx.core.http.HttpVersion.HTTP_1_0) {
       this.chunked = chunked;
     }
     return this;
   }
 }
Ejemplo n.º 3
0
 HttpClientRequestImpl(
     HttpClientImpl client,
     io.vertx.core.http.HttpMethod method,
     String host,
     int port,
     String relativeURI,
     VertxInternal vertx) {
   this.host = host;
   this.port = port;
   this.client = client;
   this.request =
       new DefaultHttpRequest(
           toNettyHttpVersion(client.getOptions().getProtocolVersion()),
           toNettyHttpMethod(method),
           relativeURI,
           false);
   this.chunked = false;
   this.method = method;
   this.vertx = vertx;
 }