Examples of HttpVersion


Examples of org.apache.http.HttpVersion

    }

    // ------------------------------------------------------------------ Tests
   
    public void testHttpVersionParsing() throws Exception {
        new HttpVersion(1, 1);
        String s = "HTTP/1.1";
        HttpVersion version = BasicHttpVersionFormat.parse(s);
        assertEquals("HTTP major version number", 1, version.getMajor());
        assertEquals("HTTP minor version number", 1, version.getMinor());
        assertEquals("HTTP version number", s, version.toString());

        s = "HTTP/123.4567";
        version = BasicHttpVersionFormat.parse(s);
        assertEquals("HTTP major version number", 123, version.getMajor());
        assertEquals("HTTP minor version number", 4567, version.getMinor());
        assertEquals("HTTP version number", s, version.toString());
    }
View Full Code Here

Examples of org.apache.http.HttpVersion

        try {
            minor = Integer.parseInt(s.substring(i1, i2));
        } catch (NumberFormatException e) {
            throw new ProtocolException("Invalid HTTP minor version number: " + s);
        }
        return new HttpVersion(major, minor);
    }
View Full Code Here

Examples of org.apache.http.HttpVersion

        response.addHeader("Content-Length", "10");
        assertTrue(reuseStrategy.keepAlive(response, context));
    }

    public void testFutureHTTP() throws Exception {
        HttpResponse response = new BasicHttpResponse(new HttpVersion(3, 45), 200, "OK");
        response.addHeader("Content-Length", "10");

        assertTrue(reuseStrategy.keepAlive(response, context));
    }
View Full Code Here

Examples of org.apache.http.HttpVersion

        Header[] headers = new Header[5];
        for (int i = 0; i < headers.length; i++) {
            headers[i] = new BasicHeader("header" + i, "value" + i);
        }
        ProtocolVersion version = new HttpVersion(1, 1);
        String body = "Lorem ipsum dolor sit amet";

        CacheEntry cacheEntry = new CacheEntry(new Date(),new Date(), version, headers, body.getBytes(),200,"OK");

        return cacheEntry;
View Full Code Here

Examples of org.apache.http.HttpVersion

        Mockito.verify(this.trigger).submitResponse(Mockito.any(BasicAsyncResponseProducer.class));
    }

    @Test
    public void testHandleRequestUnsupportedVersion() throws Exception {
        Mockito.when(this.request.getRequestLine()).thenReturn(new BasicRequestLine("GET", "/", new HttpVersion(234, 456)));

        Cancellable cancellable = this.asyncRequestHandler.handle(this.request, this.trigger, this.context);

        Assert.assertNull(cancellable);
        ArgumentCaptor<HttpResponse> argCaptor = ArgumentCaptor.forClass(HttpResponse.class);
View Full Code Here

Examples of org.apache.http.HttpVersion

        try {
            minor = Integer.parseInt(s.substring(i1, i2));
        } catch (NumberFormatException e) {
            throw new ProtocolException("Invalid HTTP minor version number: " + s);
        }
        return new HttpVersion(major, minor);

    }
View Full Code Here

Examples of org.apache.http.HttpVersion

        try {
            minor = Integer.parseInt(s.substring(i1, i2));
        } catch (NumberFormatException e) {
            throw new ProtocolException("Invalid HTTP minor version number: " + s);
        }
        return new HttpVersion(major, minor);
    }
View Full Code Here

Examples of org.apache.http.HttpVersion

            final HttpContext context) throws HttpException, IOException {

        HttpRequest request = connState.getRequest();
        context.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);
       
        HttpVersion ver;
        if (request != null) {
            ver = request.getRequestLine().getHttpVersion();
        } else {
            ver = HttpVersion.HTTP_1_0;
        }
View Full Code Here

Examples of org.apache.http.HttpVersion

            final HttpContext context) throws HttpException, IOException {

        HttpRequest request = connState.getRequest();
        context.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);

        HttpVersion ver = request.getRequestLine().getHttpVersion();

        if (!ver.lessEquals(HttpVersion.HTTP_1_1)) {
            // Downgrade protocol version if greater than HTTP/1.1
            ver = HttpVersion.HTTP_1_1;
        }

        HttpResponse response;
View Full Code Here

Examples of org.apache.http.HttpVersion

        // Update connection state
        connState.resetInput();
        connState.setRequest(request);
        connState.setInputState(ServerConnState.REQUEST_RECEIVED);
       
        HttpVersion ver = request.getRequestLine().getHttpVersion();
        if (!ver.lessEquals(HttpVersion.HTTP_1_1)) {
            // Downgrade protocol version if greater than HTTP/1.1
            ver = HttpVersion.HTTP_1_1;
        }

        HttpResponse response;
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.