Package org.apache.http.io

Examples of org.apache.http.io.HttpMessageParser


            "header2: value2\r\n" +
            "\r\n";

        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuffer = new SessionInputBufferMockup(s, "US-ASCII", params);
        HttpMessageParser parser = new DefaultResponseParser(
                inbuffer,
                BasicLineParser.DEFAULT,
                new DefaultHttpResponseFactory(),
                params);

        HttpResponse response = (HttpResponse) parser.parse();
        Assert.assertNotNull(response);
        Assert.assertEquals(HttpVersion.HTTP_1_1, response.getProtocolVersion());
        Assert.assertEquals(200, response.getStatusLine().getStatusCode());

        Header[] headers = response.getAllHeaders();
View Full Code Here


            "\r\n";

        HttpParams params = new BasicHttpParams();
        params.setParameter(ConnConnectionPNames.MAX_STATUS_LINE_GARBAGE, Integer.valueOf(2));
        SessionInputBuffer inbuffer = new SessionInputBufferMockup(s, "US-ASCII", params);
        HttpMessageParser parser = new DefaultResponseParser(
                inbuffer,
                BasicLineParser.DEFAULT,
                new DefaultHttpResponseFactory(),
                params);
        parser.parse();
    }
View Full Code Here

    @Test(expected=NoHttpResponseException.class)
    public void testResponseParsingNoResponse() throws Exception {
        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuffer = new SessionInputBufferMockup("", "US-ASCII", params);
        HttpMessageParser parser = new DefaultResponseParser(
                inbuffer,
                BasicLineParser.DEFAULT,
                new DefaultHttpResponseFactory(),
                params);
        parser.parse();
    }
View Full Code Here

            "garbage\r\n" +
            "more garbage\r\n" +
            "a lot more garbage\r\n";
        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuffer = new SessionInputBufferMockup(s, "US-ASCII", params);
        HttpMessageParser parser = new DefaultResponseParser(
                inbuffer,
                BasicLineParser.DEFAULT,
                new DefaultHttpResponseFactory(),
                params);
        parser.parse();
    }
View Full Code Here

        "garbage\r\n" +
        "more garbage\r\n" +
        "a lot more garbage\r\n";
      HttpParams params = new BasicHttpParams();
      SessionInputBuffer inbuffer = new SessionInputBufferMockup(s, "US-ASCII", params);
      HttpMessageParser parser = new DefaultResponseParser(
          inbuffer,
          BasicLineParser.DEFAULT,
          new DefaultHttpResponseFactory(),
          params);
     
      try {
          parser.parse();
          fail("ProtocolException should have been thrown");
      } catch (ProtocolException ex) {
      }
    }
View Full Code Here

        "header2: value2\r\n" +
        "\r\n";
     
      HttpParams params = new BasicHttpParams();
      SessionInputBuffer inbuffer = new SessionInputBufferMockup(s, "US-ASCII", params);
      HttpMessageParser parser = new DefaultResponseParser(
          inbuffer,
          BasicLineParser.DEFAULT,
          new DefaultHttpResponseFactory(),
          params);
     
      HttpResponse response = (HttpResponse) parser.parse();
      assertNotNull(response);
      assertEquals(HttpVersion.HTTP_1_1, response.getProtocolVersion());
      assertEquals(200, response.getStatusLine().getStatusCode());
     
      Header[] headers = response.getAllHeaders();
View Full Code Here

        "\r\n";
     
      HttpParams params = new BasicHttpParams();
      params.setParameter(ConnConnectionPNames.MAX_STATUS_LINE_GARBAGE, 2);
      SessionInputBuffer inbuffer = new SessionInputBufferMockup(s, "US-ASCII", params);
      HttpMessageParser parser = new DefaultResponseParser(
          inbuffer,
          BasicLineParser.DEFAULT,
          new DefaultHttpResponseFactory(),
          params);
     
      try {
          parser.parse();
          fail("ProtocolException should have been thrown");
      } catch (ProtocolException ex) {
      }
    }
View Full Code Here

    }

    public void testResponseParsingNoResponse() throws Exception {
      HttpParams params = new BasicHttpParams();
      SessionInputBuffer inbuffer = new SessionInputBufferMockup("", "US-ASCII", params);
      HttpMessageParser parser = new DefaultResponseParser(
          inbuffer,
          BasicLineParser.DEFAULT,
          new DefaultHttpResponseFactory(),
          params);
     
      try {
          parser.parse();
          fail("NoHttpResponseException should have been thrown");
      } catch (NoHttpResponseException ex) {
      }
    }
View Full Code Here

TOP

Related Classes of org.apache.http.io.HttpMessageParser

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.