Package org.xlightweb

Examples of org.xlightweb.HttpResponseHeader


                    @Override
                    public void run() {
                        cancel();
                       
                        if (!is100ResponseNotified) {
                            HttpResponseHeader header = new HttpResponseHeader(100);
                            header.setReason("Continue (100-continue response timeout)");
                            header.setAttribute(TIMEOUT_100_CONTINUE_RESPONSE, true);
                           
                            LOG.warning("100-continue timeout reached (" + DataConverter.toFormatedDuration(CONTINUE_TIMEOUT_MILLIS) + "). Generating local 100-continue response");
                            callResponseHandler(new HttpResponse(header));
                        }
                    }
View Full Code Here


    @SuppressWarnings("unchecked")
    public void onRequest(IHttpExchange exchange) throws IOException {

      // send response
      HttpResponseHeader responseHeader = new HttpResponseHeader(200, "text/plain");


      IHttpRequest request = exchange.getRequest();
     
      HashSet<String> headerSet = new HashSet<String>();
View Full Code Here

    public void onRequest(IHttpExchange exchange) throws IOException {
     
      int loops = exchange.getRequest().getIntParameter("loops");
      int waittime = exchange.getRequest().getIntParameter("waittime");
     
      HttpResponseHeader header = new HttpResponseHeader(200, "text/plain");
      BodyDataSink bodyDataSink = exchange.send(header);
     
      for (int i = 0; i < loops; i++) {
        bodyDataSink.write("1234567890");
        QAUtil.sleep(waittime);
View Full Code Here


    public void onRequest(IHttpExchange exchange) throws IOException {

      // send response
      HttpResponseHeader responseHeader = new HttpResponseHeader(200, "text/plain");

      IHttpRequest request = exchange.getRequest();
     
      BodyDataSink bodyDataSink = exchange.send(responseHeader);
      bodyDataSink.write("requestUri=" + request.getRequestURI() + "\r\n");
View Full Code Here

   
    public void onRequest(IHttpExchange exchange) throws IOException {
     
      String msg = exchange.getRequest().getRequestURI();
     
      HttpResponseHeader resp = new HttpResponseHeader(200, "text/plain");
      resp.setContentLength(msg.length());
     
      BodyDataSink channel = exchange.send(resp, msg.length());
      channel.write(msg);
      channel.close();
    }
View Full Code Here

   
    public void onRequest(IHttpExchange exchange) throws IOException {
     
      String msg = exchange.getRequest().getRequestURI();
     
      HttpResponseHeader resp = new HttpResponseHeader(200, "text/plain");
     
      BodyDataSink channel = exchange.send(resp);
      channel.write(msg);
      channel.close();
     
View Full Code Here

 
  private static final class RequestHandler2 implements IHttpRequestHandler {
   
    public void onRequest(IHttpExchange exchange) throws IOException {
     
      BodyDataSink bodyDataSink = exchange.send(new HttpResponseHeader(200, "text/plain"));
      bodyDataSink.write("it works");
      bodyDataSink.close();
    }
View Full Code Here

     

     

      // write response header and get out channel
      BodyDataSink outChannel = exchange.send(new HttpResponseHeader(200));

      // get set handler for the input channel
      request.getNonBlockingBody().setDataHandler(new CommandHandler(outChannel));
     
      outChannel.write("ready\r\n");
View Full Code Here

                if (header.getProtocolVersion().equalsIgnoreCase("0.9") || header.getProtocolVersion().equalsIgnoreCase("1.0")) {
                    if (LOG.isLoggable(Level.FINE)) {
                        LOG.fine("[" + getId() + "] response is " + header.getProtocolVersion() + " version");
                    }

                    HttpResponseHeader newHeader;
                    if (header.getProtocolVersion().equalsIgnoreCase("0.9")) {
                        newHeader = new HttpResponseHeader(200);
                    } else {
                        newHeader = new HttpResponseHeader(header.getStatus());
                    }
                    newHeader.copyHeaderFrom(header);
                   
                    header = newHeader;
                }
               
   
          // does caller support chunked response? if not convert it to length-based response 
          if (!AbstractHttpConnection.isAcceptingChunkedResponseBody(getRequest())) {
            if (LOG.isLoggable(Level.FINE)) {
              LOG.fine("[" + getId() + "] the requestor does not support chunked response messages (request protocol: " + getRequest().getProtocol() + "). Converting chunked response into simple response.");
            }
           
            HttpResponseHeader newHeader = new HttpResponseHeader(header.getStatus(), header.getReason());
            newHeader.copyHeaderFrom(header);
            newHeader.setProtocol(getRequest().getProtocol());
            newHeader.setHeader("Connection", "close");
           
            header = newHeader;
           
          } else {
              header.setTransferEncoding("chunked");
View Full Code Here

                if (header.getProtocolVersion().equalsIgnoreCase("0.9") || header.getProtocolVersion().equalsIgnoreCase("1.0")) {
                    if (LOG.isLoggable(Level.FINE)) {
                        LOG.fine("[" + getId() + "] response is " + header.getProtocolVersion() + " version");
                    }

                    HttpResponseHeader newHeader;
                    if (header.getProtocolVersion().equalsIgnoreCase("0.9")) {
                        newHeader = new HttpResponseHeader(200);
                    } else {
                        newHeader = new HttpResponseHeader(header.getStatus());
                    }
                    newHeader.copyHeaderFrom(header);
                   
                    header = newHeader;
                }
               
               
                // is event-stream content type?
                if (HttpUtils.hasContentType(header, "text/event-stream")) {
                    header.setHeader("Connection", "close");
                    HttpUtils.setExpireHeaders(header, 0);
                   
                   
                // does caller support chunked response? if not convert it to length-based response                   
                } else if (!AbstractHttpConnection.isAcceptingChunkedResponseBody(getRequest())) {
            if (LOG.isLoggable(Level.FINE)) {
              LOG.fine("[" + getId() + "] the requestor does not support chunked response messages (request protocol: " + getRequest().getProtocol() + "). Converting chunked response into simple response.");
            }
           
            HttpResponseHeader newHeader = new HttpResponseHeader(header.getStatus(), header.getReason());
            newHeader.copyHeaderFrom(header);
            newHeader.setProtocol(getRequest().getProtocol());
            newHeader.setHeader("Connection", "close");
           
            header = newHeader;
           
          // default
          } else {
View Full Code Here

TOP

Related Classes of org.xlightweb.HttpResponseHeader

Copyright © 2018 www.massapicom. 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.