Examples of IHttpResponseHeader


Examples of org.xlightweb.IHttpResponseHeader

        }
  }

   
    private static boolean isErrorStatusCodeRecevied(ProtocolException pe) {
        IHttpResponseHeader header = (IHttpResponseHeader) HttpClientConnection.getReceivedHeader(pe);
        if ((header != null) && (header.getStatus() >= 400)) {
            return true;
        }
       
        return false;
    }
View Full Code Here

Examples of org.xlightweb.IHttpResponseHeader

 
  private BodyDataSink sendResponseMessage(IHttpResponse response, boolean autocompress) throws IOException {

    try
      IHttpResponseHeader responseHeader = response.getResponseHeader();
     
      if (response.getStatus() == 100) {
                writeMessageSilence(response);
                return null;
View Full Code Here

Examples of org.xlightweb.IHttpResponseHeader

 
  private BodyDataSink sendResponseMessage(IHttpResponse response, boolean autocompress) throws IOException {

    try
      IHttpResponseHeader responseHeader = response.getResponseHeader();
     
      if (response.getStatus() == 100) {
                writeMessageSilence(response);
                return null;
View Full Code Here

Examples of org.xlightweb.IHttpResponseHeader

   
    public void register(HttpClientConnection con, final IHttpResponse response) {
        this.con = con;
      isHeaderReceived = true;

      IHttpResponseHeader responseHeader = response.getResponseHeader();
      responseHeaderInfo = responseHeader.getStatus() + " " + responseHeader.getReason();
      if (responseHeader.containsHeader("connection")) {
        responseHeaderInfo = responseHeaderInfo + " (connection: " + responseHeader.getHeader("connection") + ")";
      }
     
     
      if (response.hasBody()) {
        try {
View Full Code Here

Examples of org.xlightweb.IHttpResponseHeader

        }
  }

   
    private static boolean isErrorStatusCodeRecevied(ProtocolException pe) {
        IHttpResponseHeader header = (IHttpResponseHeader) HttpClientConnection.getReceivedHeader(pe);
        if ((header != null) && (header.getStatus() >= 400)) {
            return true;
        }
       
        return false;
    }
View Full Code Here

Examples of org.xlightweb.IHttpResponseHeader

      public void onResponse(IHttpResponse response) throws IOException {

        // does request contain a body?
        if (response.hasBody()) {
         
          final IHttpResponseHeader header = response.getResponseHeader();
          final List<ByteBuffer> bodyData = new ArrayList<ByteBuffer>();
         
          NonBlockingBodyDataSource orgDataSource = response.getNonBlockingBody();
          final BodyDataSink inBodyChannel = exchange.send(response.getResponseHeader());
         
          //... by a body forward handler
          BodyForwarder bodyForwardHandler = new BodyForwarder(orgDataSource, inBodyChannel) {
           
            @Override
            public void onData(NonBlockingBodyDataSource bodyDataSource, BodyDataSink bodyDataSink) throws BufferUnderflowException, IOException {
              ByteBuffer[] bufs = bodyDataSource.readByteBufferByLength(bodyDataSource.available());
                 
              for (ByteBuffer byteBuffer : bufs) {
                bodyData.add(byteBuffer.duplicate());
              }
                 
              bodyDataSink.write(bufs);
              bodyDataSink.flush();
            }
           
            @Override
            public void onComplete() {
              System.out.println(header.toString());
              try {
                System.out.println(header.toString() + DataConverter.toString(bodyData, header.getCharacterEncoding()));
              } catch (Exception e) {
                System.out.println("<body not printable>");
              }
            }
          };
          orgDataSource.setDataHandler(bodyForwardHandler);
         
        } else {
          try {
            System.out.println(response.getResponseHeader());
          } catch (Exception ignore) { }
          exchange.send(response);
        }
      }
     
      public void onException(IOException ioe) {
        exchange.sendError(500);
      }
    };
   
   
    // does request contain a body?
    if (req.hasBody()) {
     
      final IHttpRequestHeader header = req.getRequestHeader();
      final List<ByteBuffer> bodyData = new ArrayList<ByteBuffer>();
     
      // get the body
      NonBlockingBodyDataSource orgDataSource = req.getNonBlockingBody();
     
      // ... and replace it 
      final BodyDataSink inBodyChannel = exchange.forward(req.getRequestHeader(), respHdl);
     
      //... by a body forward handler
      BodyForwarder bodyForwardHandler = new BodyForwarder(orgDataSource, inBodyChannel) {
       
        @Override
        public void onData(NonBlockingBodyDataSource bodyDataSource, BodyDataSink bodyDataSink) throws BufferUnderflowException, IOException {
          ByteBuffer[] bufs = bodyDataSource.readByteBufferByLength(bodyDataSource.available());
             
          for (ByteBuffer byteBuffer : bufs) {
             bodyData.add(byteBuffer.duplicate());
          }
             
          bodyDataSink.write(bufs);
          bodyDataSink.flush();
        }
       
        @Override
        public void onComplete() {
          System.out.println(header.toString());
          try {
            System.out.println(header.toString() + DataConverter.toString(bodyData, header.getCharacterEncoding()));
          } catch (Exception e) {
            System.out.println("<body not printable>");
          }
        }
      };
View Full Code Here

Examples of org.xlightweb.IHttpResponseHeader

 
  private BodyDataSink sendResponseMessage(IHttpResponse response, boolean autocompress) throws IOException {

    try
      IHttpResponseHeader responseHeader = response.getResponseHeader();
     
      if (response.getStatus() == 100) {
                writeMessageSilence(response);
                return null;
View Full Code Here

Examples of org.xlightweb.IHttpResponseHeader

      public void onResponse(IHttpResponse response) throws IOException {

        // does request contain a body?
        if (response.hasBody()) {
         
          final IHttpResponseHeader header = response.getResponseHeader();
          final List<ByteBuffer> bodyData = new ArrayList<ByteBuffer>();
         
          NonBlockingBodyDataSource orgDataSource = response.getNonBlockingBody();
          final BodyDataSink inBodyChannel = exchange.send(response.getResponseHeader());
         
          //... by a body forward handler
          BodyForwarder bodyForwardHandler = new BodyForwarder(orgDataSource, inBodyChannel) {
           
            @Override
            public void onData(NonBlockingBodyDataSource bodyDataSource, BodyDataSink bodyDataSink) throws BufferUnderflowException, IOException {
              ByteBuffer[] bufs = bodyDataSource.readByteBufferByLength(bodyDataSource.available());
                 
              for (ByteBuffer byteBuffer : bufs) {
                bodyData.add(byteBuffer.duplicate());
              }
                 
              bodyDataSink.write(bufs);
              bodyDataSink.flush();
            }
           
            @Override
            public void onComplete() {
              System.out.println(header.toString());
              try {
                System.out.println(header.toString() + DataConverter.toString(bodyData, header.getCharacterEncoding()));
              } catch (Exception e) {
                System.out.println("<body not printable>");
              }
            }
          };
          orgDataSource.setDataHandler(bodyForwardHandler);
         
        } else {
          try {
            System.out.println(response.getResponseHeader());
          } catch (Exception ignore) { }
          exchange.send(response);
        }
      }
     
      public void onException(IOException ioe) {
        exchange.sendError(500);
      }
    };
   
   
    // does request contain a body?
    if (req.hasBody()) {
     
      final IHttpRequestHeader header = req.getRequestHeader();
      final List<ByteBuffer> bodyData = new ArrayList<ByteBuffer>();
     
      // get the body
      NonBlockingBodyDataSource orgDataSource = req.getNonBlockingBody();
     
      // ... and replace it 
      final BodyDataSink inBodyChannel = exchange.forward(req.getRequestHeader(), respHdl);
     
      //... by a body forward handler
      BodyForwarder bodyForwardHandler = new BodyForwarder(orgDataSource, inBodyChannel) {
       
        @Override
        public void onData(NonBlockingBodyDataSource bodyDataSource, BodyDataSink bodyDataSink) throws BufferUnderflowException, IOException {
          ByteBuffer[] bufs = bodyDataSource.readByteBufferByLength(bodyDataSource.available());
             
          for (ByteBuffer byteBuffer : bufs) {
             bodyData.add(byteBuffer.duplicate());
          }
             
          bodyDataSink.write(bufs);
          bodyDataSink.flush();
        }
       
        @Override
        public void onComplete() {
          System.out.println(header.toString());
          try {
            System.out.println(header.toString() + DataConverter.toString(bodyData, header.getCharacterEncoding()));
          } catch (Exception e) {
            System.out.println("<body not printable>");
          }
        }
      };
View Full Code Here

Examples of org.xlightweb.IHttpResponseHeader

        }
  }

   
    private static boolean isErrorStatusCodeRecevied(ProtocolException pe) {
        IHttpResponseHeader header = (IHttpResponseHeader) HttpClientConnection.getReceivedHeader(pe);
        if ((header != null) && (header.getStatus() >= 400)) {
            return true;
        }
       
        return false;
    }
View Full Code Here

Examples of org.xlightweb.IHttpResponseHeader

 
  private BodyDataSink sendResponseMessage(IHttpResponse response, boolean autocompress) throws IOException {

    try
      IHttpResponseHeader responseHeader = response.getResponseHeader();
     
      if (response.getStatus() == 100) {
                writeMessageSilence(response);
                return null;
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.