Package org.xlightweb

Examples of org.xlightweb.HttpResponseHeader


 
  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


  }
 
  private static final class HeaderBodyResponder implements IHttpRequestHandler {
   
    public void onRequest(IHttpExchange exchange) throws IOException {
      HttpResponseHeader header = new HttpResponseHeader(200, "text/plain", "OK");
      header.setHeader("Connection", "close");
     
      BodyDataSink bodyDataSink = exchange.send(header, 2);
      bodyDataSink.write("OK");
      bodyDataSink.close();
    }
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

    public void onRequest(IHttpExchange exchange) throws IOException {
     
      String filename = exchange.getRequest().getRequestURI();
     
      RandomAccessFile raf = new RandomAccessFile(filename, "r");
            HttpResponseHeader header = new HttpResponseHeader(200);
            header.addHeader("x-length", Long.toString(raf.length()));
            BodyDataSink outChannel = exchange.send(header, (int) raf.length());

            AsyncWriter asyncWriter = new AsyncWriter(outChannel, raf);
            asyncWriter.onWritten(0);
    }
View Full Code Here

    public void onRequest(IHttpExchange exchange) throws IOException {
     
      String filename = exchange.getRequest().getRequestURI();
     
      RandomAccessFile raf = new RandomAccessFile(filename, "r");
            HttpResponseHeader header = new HttpResponseHeader(200);
            header.addHeader("x-length", Long.toString(raf.length()));
            BodyDataSink outChannel = exchange.send(header, (int) raf.length());

            AsyncWriter asyncWriter = new AsyncWriter(outChannel, raf);
            asyncWriter.onWritten(0);
    }
View Full Code Here

     public void onRequest(IHttpExchange exchange) throws IOException {

       boolean chunkedTest = exchange.getRequest().getBooleanParameter("chunked");
      
       if (chunkedTest) {
           HttpResponseHeader header = new HttpResponseHeader(200, "text/plain");
           header.setHeader("connection", "close");
         BodyDataSink bodyDataSink = exchange.send(header);
         bodyDataSink.write("test123");
         bodyDataSink.write("456\r\n");
         bodyDataSink.close();
        
       } else {
         BodyDataSink bodyDataSink = exchange.send(new HttpResponseHeader(200, "text/plain"), 10);
         bodyDataSink.write("test123\r\n");
         bodyDataSink.write("456");
         bodyDataSink.close();
       }
    }
View Full Code Here

     public void onRequest(IHttpExchange exchange) throws IOException {

       boolean chunkedTest = exchange.getRequest().getBooleanParameter("chunked");
      
       if (chunkedTest) {
         BodyDataSink bodyDataSink = exchange.send(new HttpResponseHeader(200, "text/plain"));
         bodyDataSink.setFlushmode(FlushMode.ASYNC);
         bodyDataSink.write("test123456");
         bodyDataSink.close();
        
       } else {
        
         BodyDataSink bodyDataSink = exchange.send(new HttpResponseHeader(200, "text/plain"), 10);
         bodyDataSink.setFlushmode(FlushMode.ASYNC);
         bodyDataSink.write("test123456");
         bodyDataSink.close();
       }
    }
View Full Code Here

   
    @InvokeOn(InvokeOn.MESSAGE_RECEIVED)
    public void onRequest(IHttpExchange exchange) throws IOException {

      try {
        BodyDataSink bodyDataSink = exchange.send(new HttpResponseHeader(200, "text/plain"), LENGTH);
        bodyDataSink.setFlushmode(FlushMode.ASYNC);
        bodyDataSink.write(QAUtil.generateByteArray(LENGTH / 2));
        bodyDataSink.close();
      } catch (IOException ioe) {
        this.e = ioe;
View Full Code Here

    public void onRequest(IHttpExchange exchange) throws IOException {
     
      String filename = exchange.getRequest().getRequestURI();
     
      RandomAccessFile raf = new RandomAccessFile(filename, "r");
            HttpResponseHeader header = new HttpResponseHeader(200);
            header.addHeader("x-length", Long.toString(raf.length()));
            BodyDataSink outChannel = exchange.send(header, (int) raf.length());

            AsyncWriter asyncWriter = new AsyncWriter(outChannel, raf);
            asyncWriter.onWritten(0);
    }
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.