Examples of HttpMessage


Examples of org.apache.http.HttpMessage

        }
    }

    public void testChunkedTransferEncodingMustBeLast() throws Exception {
        SessionInputBuffer datareceiver = new SessionInputBufferMockup("0\r\n", "US-ASCII");
        HttpMessage message = new HttpMessageMockup();
       
        // lenient mode
        message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, false);
        message.addHeader("Content-Type", "unknown");
        message.addHeader("Transfer-Encoding", "chunked, identity");
        message.addHeader("Content-Length", "plain wrong");
        EntityDeserializer entitygen = new EntityDeserializer(
                new LaxContentLengthStrategy());
        HttpEntity entity = entitygen.deserialize(datareceiver, message);
        assertNotNull(entity);
        assertEquals(-1, entity.getContentLength());
        assertFalse(entity.isChunked());
        assertFalse(entity.getContent() instanceof ChunkedInputStream);

        // strict mode
        message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, true);
        try {
            entitygen.deserialize(datareceiver, message);
            fail("ProtocolException should have been thrown");
        } catch (ProtocolException ex) {
            // expected
View Full Code Here

Examples of org.apache.http.HttpMessage

        }
    }

    public void testEntityWithContentLength() throws Exception {
        SessionInputBuffer datareceiver = new SessionInputBufferMockup(new byte[] {});
        HttpMessage message = new HttpMessageMockup();
       
        // lenient mode
        message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, false);
        message.addHeader("Content-Type", "unknown");
        message.addHeader("Content-Length", "0");
        EntityDeserializer entitygen = new EntityDeserializer(
                new LaxContentLengthStrategy());
        HttpEntity entity = entitygen.deserialize(datareceiver, message);
        assertNotNull(entity);
        assertEquals(0, entity.getContentLength());
View Full Code Here

Examples of org.apache.http.HttpMessage

        assertTrue(entity.getContent() instanceof ContentLengthInputStream);
    }

    public void testEntityWithMultipleContentLength() throws Exception {
        SessionInputBuffer datareceiver = new SessionInputBufferMockup(new byte[] {'0'});
        HttpMessage message = new HttpMessageMockup();

        // lenient mode
        message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, false);
        message.addHeader("Content-Type", "unknown");
        message.addHeader("Content-Length", "0");
        message.addHeader("Content-Length", "0");
        message.addHeader("Content-Length", "1");
        EntityDeserializer entitygen = new EntityDeserializer(
                new LaxContentLengthStrategy());
        HttpEntity entity = entitygen.deserialize(datareceiver, message);
        assertNotNull(entity);
        assertEquals(1, entity.getContentLength());
        assertFalse(entity.isChunked());
        InputStream instream = entity.getContent();
        assertNotNull(instream);
        assertTrue(instream instanceof ContentLengthInputStream);
       
        // strict mode
        message.getParams().setBooleanParameter(CoreProtocolPNames.STRICT_TRANSFER_ENCODING, true);
        try {
            entitygen.deserialize(datareceiver, message);
            fail("ProtocolException should have been thrown");
        } catch (ProtocolException ex) {
            // expected
View Full Code Here

Examples of org.apache.http.HttpMessage

    protected abstract HttpMessage parseHead(SessionInputBuffer sessionBuffer)
        throws IOException, HttpException, ParseException;

    public HttpMessage parse() throws IOException, HttpException {
        HttpMessage message = null;
        try {
            message = parseHead(this.sessionBuffer);
        } catch (ParseException px) {
            throw new ProtocolException(px.getMessage(), px);
        }
        Header[] headers = AbstractMessageParser.parseHeaders(
                this.sessionBuffer,
                this.maxHeaderCount,
                this.maxLineLen,
                this.lineParser);
        message.setHeaders(headers);
        return message;
    }
View Full Code Here

Examples of org.apache.http.HttpMessage

        }
    }

    public void testEntityWithChunkTransferEncoding() throws Exception {
        HttpDataTransmitter datatransmitter = new HttpDataTransmitterMockup();
        HttpMessage message = new HttpMessageMockup();
        message.addHeader(new Header("Transfer-Encoding", "Chunked"));

        DefaultEntitySerializer entitywriter = new DefaultEntitySerializer();
        OutputStream outstream = entitywriter.doSerialize(datatransmitter, message);
        assertNotNull(outstream);
        assertTrue(outstream instanceof ChunkedOutputStream);
View Full Code Here

Examples of org.apache.http.HttpMessage

        assertTrue(outstream instanceof ChunkedOutputStream);
    }

    public void testEntityWithIdentityTransferEncoding() throws Exception {
        HttpDataTransmitter datatransmitter = new HttpDataTransmitterMockup();
        HttpMessage message = new HttpMessageMockup();
        message.addHeader(new Header("Transfer-Encoding", "Identity"));

        DefaultEntitySerializer entitywriter = new DefaultEntitySerializer();
        OutputStream outstream = entitywriter.doSerialize(datatransmitter, message);
        assertNotNull(outstream);
        assertTrue(outstream instanceof IdentityOutputStream);
View Full Code Here

Examples of org.jboss.netty.handler.codec.http.HttpMessage

  @Override
  public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
          throws Exception {

      Object msg = e.getMessage();
      HttpMessage currentMessage = this.currentMessage;

      if (msg instanceof HttpMessage) {
          HttpMessage m = (HttpMessage) msg;
          if (m.isChunked()) {
              // A chunked message - remove 'Transfer-Encoding' header,
              // initialize the cumulative buffer, and wait for incoming chunks.
              List<String> encodings = m.getHeaders(HttpHeaders.Names.TRANSFER_ENCODING);
              encodings.remove(HttpHeaders.Values.CHUNKED);
              if (encodings.isEmpty()) {
                  m.removeHeader(HttpHeaders.Names.TRANSFER_ENCODING);
              }
              m.setContent(ChannelBuffers.dynamicBuffer(e.getChannel().getConfig().getBufferFactory()));
              this.currentMessage = m;
          } else {
              // Not a chunked message - pass through.
              this.currentMessage = null;
              ctx.sendUpstream(e);
View Full Code Here

Examples of org.jclouds.http.HttpMessage

  
   @Test
   public void testAlreadyHasMD5() {
      Payload payload = Payloads.newPayload("foo");
      payload.getContentMetadata().setContentMD5(new byte[] {});
      HttpMessage payloadEnclosing = HttpMessage.builder().payload(payload).build();
      assertEquals(fn.apply(payloadEnclosing), new byte[] {});
   }
View Full Code Here

Examples of org.parosproxy.paros.network.HttpMessage

    private long sessionId = 0;
  private int historyType = HistoryReference.TYPE_MANUAL;
  private HttpMessage httpMessage = null;
 
  public RecordHistory() {
      httpMessage = new HttpMessage()
   
  }
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.