Examples of IHttpRequest


Examples of org.xlightweb.IHttpRequest

    // create exchange
    ClientExchange exchange = new ClientExchange(this, getWorkerpool());
   
    // create data body sink / data body source pair
    IBodySinkPair pair = HttpClientConnection.newBodySinkPair(null, exchange.getExecutor(), requestHeader.getCharacterEncoding());
    IHttpRequest request = new HttpRequest(requestHeader, pair.getBodyDataSource());

    // init and process it
    exchange.init(request, responseHandler);
    httpClientRequestHandlerChain.onRequest(exchange);
     
View Full Code Here

Examples of org.xlightweb.IHttpRequest

   * {@inheritDoc}
   */
  @Execution(Execution.NONTHREADED)
  public void onRequest(IHttpExchange exchange) throws IOException {
   
    IHttpRequest request = exchange.getRequest();
   
    if (!hasProxytoUse(request)) {
      exchange.forward(request);
      return;
    }
     
    if (request.isSecure()) {
      forwardSSL(exchange);
     
    } else {
      forwardNonSSL(exchange);
    }
View Full Code Here

Examples of org.xlightweb.IHttpRequest

  }
 
 
  private void forwardNonSSL(IHttpExchange exchange) throws IOException {
   
    IHttpRequest request = exchange.getRequest();
   
    if (proxyUser != null) {
      if (proxyUserPassword != null) {
        request.addHeader("Proxy-Authorization", "Basic " + proxyUserPassword);
       
      } else {
        if (LOG.isLoggable(Level.FINE)) {
          LOG.fine("proxy password is not send send error");
        }
        exchange.sendError(new IOException("proxy user password is not set (hint: usage <HttpClient>.setProxyPassword(...)"));
        return;
      }
    }
   
    IHttpRequest wrappedRequest = null;
    if (request.hasBody()) {
      wrappedRequest = new HttpRequest(new NonSSLRequestHeaderWrapper(request.getRequestHeader()), request.getNonBlockingBody());
    } else {
      wrappedRequest = new HttpRequest(new NonSSLRequestHeaderWrapper(request.getRequestHeader()));
    }
View Full Code Here

Examples of org.xlightweb.IHttpRequest

        exchange.sendError(ioe);
      }
    };
   
   
    IHttpRequest request = exchange.getRequest();
   


    try {
      Map<String, List<String>> cookieHeaders = cookieManager.get(getRequestURI(exchange));
     
     
      for (Entry<String, List<String>> entry : cookieHeaders.entrySet()) {
       
        if (!entry.getValue().isEmpty()) {
          StringBuilder sb = new StringBuilder();
         
          List<String> cookies = entry.getValue();
          for (int i = 0; i < cookies.size(); i++) {
            sb.append(cookies.get(i));
            if ((i +1) < cookies.size()) {
              sb.append("; ");
            }
          }
         
          if ((request.getHeader("Cookie") != null) && Boolean.parseBoolean(System.getProperty(COOKIE_WARNING_KEY, "true"))) {
            LOG.warning("cookie is set manually and auto handle cookie is activate " +
                    "(hint: deactivate auto handling cookie by calling <httpClient>.setAutoHandleCookies(false) or " +
                    "suppress this message by setting system property 'org.xlightweb.client.cookieHandler.cookieWarning=false')");
          }         
          request.addHeader(entry.getKey(), sb.toString());
        }
      }
    } catch (URISyntaxException ue) {
      if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("invcalid URI. ignore handling cookies " + ue.toString());
View Full Code Here

Examples of org.xlightweb.IHttpRequest

   */
  @InvokeOn(InvokeOn.MESSAGE_RECEIVED)
  @Execution(Execution.NONTHREADED)
  public void onRequest(IHttpExchange exchange) throws IOException {
 
    IHttpRequest request = exchange.getRequest();
    exchange.forward(request, new RedirectedHandler(HttpUtils.copy(request), exchange));
  }
View Full Code Here

Examples of org.xlightweb.IHttpRequest

   * {@inheritDoc}
   */
  @InvokeOn(InvokeOn.MESSAGE_RECEIVED)
  public void onRequest(IHttpExchange exchange) throws IOException {
 
    IHttpRequest request = exchange.getRequest();
    exchange.forward(request, new ResponseHandler(HttpUtils.copy(request), exchange));
  }
View Full Code Here

Examples of org.xlightweb.IHttpRequest

  /**
   * {@inheritDoc}
   */
  public void onRequest(final IHttpExchange exchange) throws IOException {

      IHttpRequest request = exchange.getRequest();
     
      Boolean retry = (Boolean) request.getAttribute(RETRY_KEY);
      if (retry == null) {
          retry = true;
      }
     
      if (retry) {
          // handle GET and Delete request
          if (request.getMethod().equalsIgnoreCase("GET"|| request.getMethod().equalsIgnoreCase("DELETE")) {
              BodylessRetryResponseHandler retryHandler = new BodylessRetryResponseHandler(exchange, request.getRequestHeader().copy());
              exchange.forward(request, retryHandler);
              return;
             
          // handle PUT
          } else if (request.getMethod().equalsIgnoreCase("PUT")) { 
              BodyRetryResponseHandler retryHandler = new BodyRetryResponseHandler(exchange, request.getRequestHeader().copy());
             
              final BodyDataSink dataSink = exchange.forward(request.getRequestHeader(), retryHandler);
              dataSink.setFlushmode(FlushMode.ASYNC);
             
              // BodyDataSink
             
              DuplicatingBodyForwarder forwarder = new DuplicatingBodyForwarder(request.getNonBlockingBody(), new BodyDataSinkAdapter(dataSink), retryHandler);
              request.getNonBlockingBody().setDataHandler(forwarder);
              return;
          }
      }
     
      exchange.forward(request);
View Full Code Here

Examples of org.xlightweb.IHttpRequest

 
  private BodyDataSink sendInternal(IHttpRequestHeader requestHeader, IHttpResponseHandler responseHandler) throws IOException, ConnectException {
    lastTimeRequestSentMillis = System.currentTimeMillis();
   
    BodyDataSink dataSink = HttpClientConnection.newInMemoryBodyDataSink(requestHeader.getCharacterEncoding(), pool.getWorkerpool());
    IHttpRequest request = new HttpRequest(requestHeader, HttpClientConnection.getDataSourceOfInMemoryBodyDataSink(dataSink));

    send(request, responseHandler);   
    return dataSink;
  }
View Full Code Here

Examples of org.xlightweb.IHttpRequest

     
      public void onRequest(IHttpExchange exchange) throws IOException, BadMessageException {
         
          lastConRef.set((AbstractHttpConnection) exchange.getConnection());
         
          IHttpRequest request = exchange.getRequest();
         
          if (request.getBooleanParameter("isWaitForBody", false)) {
              request.getBody().readString();
         
         
          IHttpResponse response = new HttpResponse(200, "text/plain", "1234567890");
          response.setHeader("Connection", "close");
           
View Full Code Here

Examples of org.xlightweb.IHttpRequest

  /**
   * {@inheritDoc}
   */
  public void onRequest(IHttpExchange exchange) throws IOException {
   
    IHttpRequest request = exchange.getRequest();
   
    if (!hasProxytoUse(request)) {
      exchange.forward(request);
      return;
    }
     
    if (request.isSecure()) {
      forwardSSL(exchange);
     
    } else {
      forwardNonSSL(exchange);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.