Package org.apache.http

Examples of org.apache.http.ProtocolVersion


        return this.uri;
    }
   
    public RequestLine getRequestLine() {
        String method = getMethod();
        ProtocolVersion ver = getProtocolVersion();
        URI uri = getURI();
        String uritext = null;
        if (uri != null) {
            uritext = uri.toASCIIString();
        }
View Full Code Here


        this.uri = uri;
    }

    public RequestLine getRequestLine() {
        String method = getMethod();
        ProtocolVersion ver = getProtocolVersion();
        String uritext = null;
        if (uri != null) {
            uritext = uri.toASCIIString();
        }
        if (uritext == null || uritext.length() == 0) {
View Full Code Here

        buffer.append(host);
        buffer.append(':');
        buffer.append(Integer.toString(port));
       
        String authority = buffer.toString();
        ProtocolVersion ver = HttpProtocolParams.getVersion(params);
        HttpRequest req = new BasicHttpRequest
            ("CONNECT", authority, ver);

        return req;
    }
View Full Code Here

      if(!request.getMethod().equalsIgnoreCase(httpMethod))
        throw new IllegalArgumentException(String.format("Expected %s, but was %s", httpMethod, request.getMethod()));

      if(request.getURI().toString().equals(uri)) {
        HttpResponse response = new BasicHttpResponse(new ProtocolVersion("HTTP", 1, 1), 200, "OK");
        BasicHttpEntity entity = new BasicHttpEntity();
        if(contentLocation != null)
          response.addHeader(new BasicHeader("Content-Location", contentLocation));
        entity.setContentEncoding(charset);
        entity.setContentType(this.contentType);
View Full Code Here

        return new ErrorResponseProducer(
                HttpVersion.HTTP_1_0, code, NStringEntity.create(message), false);
    }

    private HttpResponse create100Continue(final HttpRequest request) {
        ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
        if (!ver.lessEquals(HttpVersion.HTTP_1_1)) {
            // Downgrade protocol version if greater than HTTP/1.1
            ver = HttpVersion.HTTP_1_1;
        }
        return new BasicHttpResponse(ver, HttpStatus.SC_CONTINUE, "Continue");
    }
View Full Code Here

    @Test
    public void shouldMapHttpClientResponseToHttpResponse() throws IOException {
        // given
        CloseableHttpResponse httpClientResponse = mock(CloseableHttpResponse.class);
        when(httpClientResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 500, "Server Error"));
        when(httpClientResponse.getAllHeaders()).thenReturn(new org.apache.http.Header[]{
                new BasicHeader("header_name", "header_value"),
                new BasicHeader("Set-Cookie", "cookie_name=cookie_value")
        });
        when(httpClientResponse.getEntity()).thenReturn(new StringEntity("some_other_body"));
View Full Code Here

    @Test
    public void shouldFilterHeader() throws IOException {
        // given
        CloseableHttpResponse httpClientResponse = mock(CloseableHttpResponse.class);
        when(httpClientResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 500, "Server Error"));
        when(httpClientResponse.getAllHeaders()).thenReturn(new org.apache.http.Header[]{
                new BasicHeader("header_name", "header_value"),
                new BasicHeader("Content-Encoding", "gzip"),
                new BasicHeader("Content-Length", "1024"),
                new BasicHeader("Transfer-Encoding", "chunked")
View Full Code Here

    @Test
    public void shouldIgnoreIncorrectlyFormattedCookies() throws IOException {
        // given
        CloseableHttpResponse httpClientResponse = mock(CloseableHttpResponse.class);
        when(httpClientResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 500, "Server Error"));
        when(httpClientResponse.getAllHeaders()).thenReturn(new org.apache.http.Header[]{
                new BasicHeader("Set-Cookie", "valid_name=valid_value"),
                new BasicHeader("Set-Cookie", "=invalid"),
                new BasicHeader("Set-Cookie", "valid_name="),
                new BasicHeader("Set-Cookie", "invalid"),
View Full Code Here

        buffer.append(host);
        buffer.append(':');
        buffer.append(Integer.toString(port));

        String authority = buffer.toString();
        ProtocolVersion ver = HttpProtocolParams.getVersion(params);
        HttpRequest req = new BasicHttpRequest
            ("CONNECT", authority, ver);

        return req;
    }
View Full Code Here

    }
   
    private String generateViaHeader(HttpMessage msg) {
        final VersionInfo vi = VersionInfo.loadVersionInfo("org.apache.http.client", getClass().getClassLoader());
        final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE;
        final ProtocolVersion pv = msg.getProtocolVersion();
        if ("http".equalsIgnoreCase(pv.getProtocol())) {
            return String.format("%d.%d localhost (Apache-HttpClient/%s (cache))",
                pv.getMajor(), pv.getMinor(), release);
        } else {
            return String.format("%s/%d.%d localhost (Apache-HttpClient/%s (cache))",
                    pv.getProtocol(), pv.getMajor(), pv.getMinor(), release);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.http.ProtocolVersion

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.