Package org.apache.http

Examples of org.apache.http.HttpRequestFactory


    }

    public void testLineLimitForHeader() throws Exception {
        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
        HttpRequestFactory requestFactory = new DefaultHttpRequestFactory();

        params.setIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, 0);
        HttpRequestParser requestParser = new HttpRequestParser(inbuf, null, requestFactory, params);
        requestParser.fillBuffer(newChannel("GET /whatever HTTP/1.0\r\nHeader: one\r\n\r\n"));
        requestParser.parse();
View Full Code Here


    }

    public void testLineLimitForFoldedHeader() throws Exception {
        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
        HttpRequestFactory requestFactory = new DefaultHttpRequestFactory();

        params.setIntParameter(CoreConnectionPNames.MAX_HEADER_COUNT, 2);
        params.setIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, 15);       
        HttpRequestParser requestParser = new HttpRequestParser(inbuf, null, requestFactory, params);
        try {
View Full Code Here

    }

    public void testMaxHeaderCount() throws Exception {
        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuf = new SessionInputBufferImpl(1024, 128, params);
        HttpRequestFactory requestFactory = new DefaultHttpRequestFactory();

        params.setIntParameter(CoreConnectionPNames.MAX_HEADER_COUNT, 2);
        HttpRequestParser requestParser = new HttpRequestParser(inbuf, null, requestFactory, params);
        requestParser.fillBuffer(newChannel("GET /whatever HTTP/1.0\r\nHeader: one\r\nHeader: two\r\n\r\n"));
        requestParser.parse();
View Full Code Here

    }

    public void testDetectLineLimitEarly() throws Exception {
        HttpParams params = new BasicHttpParams();
        SessionInputBuffer inbuf = new SessionInputBufferImpl(2, 128, params);
        HttpRequestFactory requestFactory = new DefaultHttpRequestFactory();

        params.setIntParameter(CoreConnectionPNames.MAX_LINE_LENGTH, 2);
        HttpRequestParser requestParser = new HttpRequestParser(inbuf, null, requestFactory, params);
        ReadableByteChannel channel = newChannel("GET / HTTP/1.0\r\nHeader: one\r\n\r\n");
        assertEquals(2, requestParser.fillBuffer(channel));
View Full Code Here

        httpexec.setParams(params);
       
        Scheme http = (Scheme) beanfactory.getBean("http-scheme");
        HttpHost host = new HttpHost("www.yahoo.com", 80, http);

        HttpRequestFactory requestfactory = (HttpRequestFactory) beanfactory.getBean("http-request-factory");
        HttpClientConnection conn = (HttpClientConnection) beanfactory.getBean("http-connection");
        ConnectionReuseStrategy connStrategy = (ConnectionReuseStrategy) beanfactory.getBean("conn-reuse-strategy");
        conn.setTargetHost(host);
        try {
            HttpRequest request1 = requestfactory.newHttpRequest("GET", "/");
            HttpResponse response1 = httpexec.execute(request1, conn);
            System.out.println("<< Response: " + response1.getStatusLine());
            System.out.println(EntityUtils.toString(response1.getEntity()));
            System.out.println("==============");
            if (connStrategy.keepAlive(response1)) {
                System.out.println("Connection kept alive...");
            } else {
                conn.close();
                System.out.println("Connection closed...");
            }
            HttpRequest request2 = requestfactory.newHttpRequest("GET", "/stuff");
            HttpResponse response2 = httpexec.execute(request2, conn);
            System.out.println("<< Response: " + response2.getStatusLine());
            System.out.println(EntityUtils.toString(response2.getEntity()));
            System.out.println("==============");
            if (connStrategy.keepAlive(response2)) {
View Full Code Here

        return newChannel(s, "US-ASCII");
    }

    public void testSimpleParsing() throws Exception {
        SessionInputBuffer inbuf = new SessionInputBuffer(1024, 128);
        HttpRequestFactory requestFactory = new DefaultHttpRequestFactory();
        HttpRequestParser requestParser = new HttpRequestParser(inbuf, requestFactory);
        requestParser.fillBuffer(newChannel("GET /whatever HTTP/1.1\r\nSome header: stuff\r\n\r\n"));
        HttpRequest request = (HttpRequest) requestParser.parse();
        assertNotNull(request);
        assertEquals("/whatever", request.getRequestLine().getUri());
View Full Code Here

        assertEquals(1, request.getAllHeaders().length);
    }

    public void testParsingChunkedMessages() throws Exception {
        SessionInputBuffer inbuf = new SessionInputBuffer(1024, 128);
        HttpRequestFactory requestFactory = new DefaultHttpRequestFactory();
        HttpRequestParser requestParser = new HttpRequestParser(inbuf, requestFactory);

        requestParser.fillBuffer(newChannel("GET /whatev"));
        HttpRequest request = (HttpRequest) requestParser.parse();
        assertNull(request);
View Full Code Here

       
    }

    public void testParsingFoldedHeaders() throws Exception {
        SessionInputBuffer inbuf = new SessionInputBuffer(1024, 128);
        HttpRequestFactory requestFactory = new DefaultHttpRequestFactory();
        HttpRequestParser requestParser = new HttpRequestParser(inbuf, requestFactory);

        requestParser.fillBuffer(newChannel("GET /whatev"));
        HttpRequest request = (HttpRequest) requestParser.parse();
        assertNull(request);
View Full Code Here

        assertEquals("stuff more stuff", request.getFirstHeader("Some header").getValue());
    }
   
    public void testParsingBadlyFoldedFirstHeader() throws Exception {
        SessionInputBuffer inbuf = new SessionInputBuffer(1024, 128);
        HttpRequestFactory requestFactory = new DefaultHttpRequestFactory();
        HttpRequestParser requestParser = new HttpRequestParser(inbuf, requestFactory);

        requestParser.fillBuffer(newChannel("GET /whatev"));
        HttpRequest request = (HttpRequest) requestParser.parse();
        assertNull(request);
View Full Code Here

        assertEquals("stuff more stuff", request.getFirstHeader("Some header").getValue());
    }
   
    public void testParsingEmptyFoldedHeader() throws Exception {
        SessionInputBuffer inbuf = new SessionInputBuffer(1024, 128);
        HttpRequestFactory requestFactory = new DefaultHttpRequestFactory();
        HttpRequestParser requestParser = new HttpRequestParser(inbuf, requestFactory);

        requestParser.fillBuffer(newChannel("GET /whatev"));
        HttpRequest request = (HttpRequest) requestParser.parse();
        assertNull(request);
View Full Code Here

TOP

Related Classes of org.apache.http.HttpRequestFactory

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.