Package org.apache.http

Examples of org.apache.http.RequestLine


        this.buffer.clear();
        int i = this.datareceiver.readLine(this.buffer);
        if (i == -1) {
            throw new ConnectionClosedException("Client closed connection");
        }
        RequestLine requestline = RequestLine.parse(this.buffer, 0, this.buffer.length());
        HttpRequest request = this.requestfactory.newHttpRequest(requestline);
        request.getParams().setDefaults(params);
        return request;
    }
View Full Code Here


        junit.textui.TestRunner.main(testCaseName);
    }

    public void testConstructor() throws Exception {
        new BasicHttpRequest("GET", "/stuff");
        new BasicHttpRequest(new RequestLine("GET", "/stuff", HttpVersion.HTTP_1_1));
        try {
            new BasicHttpRequest(null, "/stuff");
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
            // expected
View Full Code Here

        assertEquals(HttpVersion.HTTP_1_0, request.getRequestLine().getHttpVersion());
    }

    public void testRequestLine2() throws Exception {
        HttpRequest request = new BasicHttpRequest(
                new RequestLine("GET", "/stuff", HttpVersion.HTTP_1_0));
        assertEquals("GET", request.getRequestLine().getMethod());
        assertEquals("/stuff", request.getRequestLine().getUri());
        assertEquals(HttpVersion.HTTP_1_0, request.getRequestLine().getHttpVersion());
    }
View Full Code Here

    @Override
    protected HttpMessage createMessage(final CharArrayBuffer buffer)
            throws HttpException, ParseException {
        ParserCursor cursor = new ParserCursor(0, buffer.length());
        RequestLine requestLine = lineParser.parseRequestLine(buffer, cursor);
        return this.requestFactory.newHttpRequest(requestLine);
    }
View Full Code Here

    @Override
    protected HttpRequest createMessage(final CharArrayBuffer buffer)
            throws HttpException, ParseException {
        ParserCursor cursor = new ParserCursor(0, buffer.length());
        RequestLine requestLine = lineParser.parseRequestLine(buffer, cursor);
        return this.requestFactory.newHttpRequest(requestLine);
    }
View Full Code Here

        this.buffer.clear();
        int i = this.datareceiver.readLine(this.buffer);
        if (i == -1) {
            throw new ConnectionClosedException("Client closed connection");
        }
        RequestLine requestline = BasicRequestLine.parse(this.buffer, 0, this.buffer.length());
        return this.requestfactory.newHttpRequest(requestline);
    }
View Full Code Here

        this.requestFactory = requestFactory;
    }

    protected HttpMessage createMessage(final CharArrayBuffer buffer)
            throws HttpException {
        RequestLine requestLine = BasicRequestLine.parse(buffer, 0, buffer.length());
        return this.requestFactory.newHttpRequest(requestLine);
    }
View Full Code Here

        }
    }

    protected void doService(final HttpRequest request, final HttpResponse response)
            throws HttpException, IOException {
        RequestLine reqline = request.getRequestLine();
        if (LOG.isDebugEnabled()) {
            LOG.debug("Request method: " + reqline.getMethod());
            LOG.debug("Target URI: " + reqline.getUri());
        }

        HttpVersion ver = reqline.getHttpVersion();
        if (!ver.lessEquals(HttpVersion.HTTP_1_1)) {
            throw new UnsupportedHttpVersionException("Unsupported HTTP version: " + ver);
        }

        MessageContext msgContext = new MessageContext();
View Full Code Here

        }
    }


    public void testRLFormatting() throws Exception {
        RequestLine requestline = new BasicRequestLine("GET", "/stuff", HttpVersion.HTTP_1_1);
        String s = BasicLineFormatter.formatRequestLine(requestline, null);
        assertEquals("GET /stuff HTTP/1.1", s);
    }
View Full Code Here

    }

       
    public void testRLParseSuccess() throws Exception {
        //typical request line
        RequestLine requestline = BasicLineParser.parseRequestLine
            ("GET /stuff HTTP/1.1", null);
        assertEquals("GET /stuff HTTP/1.1", requestline.toString());
        assertEquals("GET", requestline.getMethod());
        assertEquals("/stuff", requestline.getUri());
        assertEquals(HttpVersion.HTTP_1_1, requestline.getProtocolVersion());

        //Lots of blanks
        requestline = BasicLineParser.parseRequestLine
            ("  GET    /stuff   HTTP/1.1   ", null);
        assertEquals("GET /stuff HTTP/1.1", requestline.toString());
        assertEquals("GET", requestline.getMethod());
        assertEquals("/stuff", requestline.getUri());
        assertEquals(HttpVersion.HTTP_1_1, requestline.getProtocolVersion());

        //this is not strictly valid, but is lenient
        requestline = BasicLineParser.parseRequestLine
            ("\rGET /stuff HTTP/1.1", null);
        assertEquals("GET", requestline.getMethod());
        assertEquals("/stuff", requestline.getUri());
        assertEquals(HttpVersion.HTTP_1_1, requestline.getProtocolVersion());
    }
View Full Code Here

TOP

Related Classes of org.apache.http.RequestLine

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.