Examples of ProtocolVersion


Examples of org.apache.http.ProtocolVersion

        public void handle(
                final HttpRequest request,
                final HttpResponse response,
                final HttpContext context) throws HttpException, IOException {
            ProtocolVersion httpversion = request.getRequestLine().getProtocolVersion();
            response.setStatusLine(httpversion, HttpStatus.SC_OK);
            response.addHeader(new BasicHeader("Set-Cookie", "name1=value1; path=/test"));
            StringEntity entity = new StringEntity("whatever");
            response.setEntity(entity);
        }
View Full Code Here

Examples of org.apache.http.ProtocolVersion

        public void handle(
                final HttpRequest request,
                final HttpResponse response,
                final HttpContext context) throws HttpException, IOException {
            ProtocolVersion httpversion = request.getRequestLine().getProtocolVersion();
            response.setStatusLine(httpversion, HttpStatus.SC_OK);
            response.addHeader(new BasicHeader("Set-Cookie", "name1=value1; Path=\"/test\"; Version=1"));
            response.addHeader(new BasicHeader("Set-Cookie2", "name2=value2; Path=\"/test\"; Version=1"));
            StringEntity entity = new StringEntity("whatever");
            response.setEntity(entity);
View Full Code Here

Examples of org.apache.http.ProtocolVersion

        public void handle(
                final HttpRequest request,
                final HttpResponse response,
                final HttpContext context) throws HttpException, IOException {
            ProtocolVersion httpversion = request.getRequestLine().getProtocolVersion();
            response.setStatusLine(httpversion, HttpStatus.SC_OK);
            response.addHeader(new BasicHeader("Set-Cookie2", "name2=value2; Path=\"/test\"; Version=2"));
            StringEntity entity = new StringEntity("whatever");
            response.setEntity(entity);
        }
View Full Code Here

Examples of org.apache.http.ProtocolVersion

        public void handle(
                final HttpRequest request,
                final HttpResponse response,
                final HttpContext context) throws HttpException, IOException {
            ProtocolVersion httpversion = request.getRequestLine().getProtocolVersion();
            response.setStatusLine(httpversion, HttpStatus.SC_OK);
            response.addHeader(new BasicHeader("Set-Cookie", "name=wrong; Path=/test"));
            response.addHeader(new BasicHeader("Set-Cookie2", "name=right; Path=\"/test\"; Version=1"));
            StringEntity entity = new StringEntity("whatever");
            response.setEntity(entity);
View Full Code Here

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

Examples of org.apache.http.ProtocolVersion

        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

Examples of org.apache.http.ProtocolVersion

        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

Examples of org.apache.http.ProtocolVersion

      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

Examples of org.apache.http.ProtocolVersion

        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

Examples of org.apache.http.ProtocolVersion

    @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
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.