Package jade.imtp.leap.http

Examples of jade.imtp.leap.http.HTTPRequest


  NIOJICPConnection connection;
  private static Logger log = Logger.getLogger(NIOHTTPHelper.class.getName());


  public static ByteBuffer readByteBufferFromHttp(InputStream is) throws IOException {
    HTTPRequest request = new HTTPRequest();
    request.readFrom(is);
    if (is.markSupported()) {
      is.mark(2);
      if (is.read() != -1) {
        is.reset();
        throw new IOException("bytes left in stream after constructing HTTPRequest");
      }
    }
    if (request.getMethod().equals("GET")) {
      String recipientID = request.getField(RECIPIENT_ID_FIELD);
      JICPPacket pkt = new JICPPacket(JICPProtocol.CONNECT_MEDIATOR_TYPE, JICPProtocol.DEFAULT_INFO, recipientID, null);
      ByteBuffer b = ByteBuffer.allocateDirect(pkt.getLength());
      MyOut out = new MyOut(b);
      pkt.writeTo(out);
      b.flip();
      return b;
    } else {
      // Read the JICPPacket from the HTTP request payload
      byte[] a = request.getPayload();
      ByteBuffer b = ByteBuffer.allocateDirect(a.length);
      MyOut out = new MyOut(b);
      out.write(a, 0, a.length);
      b.flip();
      return b;
View Full Code Here

TOP

Related Classes of jade.imtp.leap.http.HTTPRequest

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.