Package org.xlightweb

Examples of org.xlightweb.HttpResponse


    private IHttpRequest request = null;
   
    public void onRequest(IHttpExchange exchange) throws IOException {
      this.request = exchange.getRequest();
     
      exchange.send(new HttpResponse(200, "text/plain", "OK"));
    }
View Full Code Here


     
    private void sendNotHandledError(final IHttpResponseHandler responseHandler) {
       
      try {
        final IHttpResponse response = new HttpResponse(404, "text/html", generateErrorMessageHtml(404, null, getId()));
   
        Runnable task = new Runnable() {
           
          public void run() {
            try {
View Full Code Here

      if (isResponseCommitted()) {
        throw new IllegalStateException("response is already committed");
      }
     
      try {
        send(new HttpResponse(errorCode, "text/html", generateErrorMessageHtml(errorCode, msg, getId())));
      } catch (IOException ioe) {
        if (LOG.isLoggable(Level.FINE)) {
          LOG.fine("could not send error message " + errorCode + " reason " + ioe.toString());
        }
        destroy();
View Full Code Here

 
  private static final class TransactionServerHandler implements IHttpRequestHandler {
   
    public void onRequest(IHttpExchange exchange) throws IOException {
      ((HttpServerConnection) exchange.getConnection()).setMaxTransactions(5);
      exchange.send(new HttpResponse(200, "text/plain", "OK"));
    }
View Full Code Here

  private static final class RequestTimeoutServerHandler implements IHttpRequestHandler {
   
    public void onRequest(IHttpExchange exchange) throws IOException {
      ((HttpServerConnection) exchange.getConnection()).setRequestTimeoutMillis(1000);
      exchange.send(new HttpResponse(200, "text/plain", "OK"));
    }
View Full Code Here


  private static final class ServerHandler implements IHttpRequestHandler {
   
    public void onRequest(IHttpExchange exchange) throws IOException {
      exchange.send(new HttpResponse(200, "text/plain", "OK"));
    }
View Full Code Here

       
        IHttpRequestHandler rh2 = new IHttpRequestHandler() {
           
            public void onRequest(IHttpExchange exchange) throws IOException, BadMessageException {
                IHttpRequest request = exchange.getRequest();
                exchange.send(new HttpResponse(200, request.getBody().readString()));
            }
        };
        chain.addLast(rh2);

       
View Full Code Here

    private AtomicInteger countDisconnected = new AtomicInteger();
   
   
    public void onRequest(IHttpExchange exchange) throws IOException, BadMessageException {
      if (exchange.getRequest().getPathInfo().startsWith("/s/")) {
        exchange.send(new HttpResponse(200, "text/plain", "test"));
      } else {
        exchange.send(new HttpResponse(400));
      }
    }
View Full Code Here

          header.setHeader("Connection", "close");
          header.setProtocol(getRequest().getProtocol());
        }
       
      } catch (Exception e) {
        HttpResponse errorResponse = null;
        if (HttpUtils.isShowDetailedError()) {
          errorResponse = new HttpResponse(400, "text/html", generateErrorMessageHtml(400, DataConverter.toString(e), getId()));
         
        } else {
          errorResponse = new HttpResponse(400, "text/html", generateErrorMessageHtml(400, HttpUtils.getReason(400), getId()));
        }
        setResponseCommited(true);
        HttpServerConnection.this.sendResponseMessage(errorResponse);
        throw new IOException(e.toString());
      }
View Full Code Here

            response.getResponseHeader().setProtocol(getRequest().getProtocol());
            response.getResponseHeader().setHeader("Connection", "close");
          }
        }
      } catch (Exception e) {
        HttpResponse errorResponse = null;
        if (HttpUtils.isShowDetailedError()) {
          errorResponse = new HttpResponse(400, "text/html", generateErrorMessageHtml(400, DataConverter.toString(e), getId()));
         
        } else {
          errorResponse = new HttpResponse(400, "text/html", generateErrorMessageHtml(400, HttpUtils.getReason(400), getId()));
        }
        setResponseCommited(true);
        HttpServerConnection.this.sendResponseMessage(errorResponse);
        throw new IOException(e.toString());
      }
View Full Code Here

TOP

Related Classes of org.xlightweb.HttpResponse

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.