Example usage for org.apache.http.message BasicRequestLine BasicRequestLine

List of usage examples for org.apache.http.message BasicRequestLine BasicRequestLine

Introduction

In this page you can find the example usage for org.apache.http.message BasicRequestLine BasicRequestLine.

Prototype

public BasicRequestLine(String str, String str2, ProtocolVersion protocolVersion) 

Source Link

Usage

From source file:ste.web.http.api.BugFreeRRequest.java

@Test
public void constructor_with_request_line() throws Throwable {
    RRequest r = new RRequest(new BasicRequestLine("POST", TEST_API_URI05, HttpVersion.HTTP_1_1));

    then(r.getAction()).isEqualTo("get");
    then(r.getResource()).containsExactly("items", "10", "sets", "5", "subsets", "2");
}

From source file:org.esigate.http.IncomingRequest.java

public static Builder builder(String uri) {
    return new Builder(new BasicRequestLine("GET", uri, HttpVersion.HTTP_1_1));
}

From source file:org.archive.modules.fetcher.BasicExecutionAwareRequest.java

/**
 * Returns the request line of this request.
 *
 * @see #BasicHttpRequest(String, String)
 *//*  w  w  w  .  ja  v  a  2  s .c  o  m*/
public RequestLine getRequestLine() {
    if (this.requestline == null) {
        this.requestline = new BasicRequestLine(this.method, this.uri, HttpVersion.HTTP_1_1);
    }
    return this.requestline;
}

From source file:no.ntnu.idi.socialhitchhiking.client.RequestTask.java

/**
 * Constructor for preparing request to server
 * @param addr/*  www  .  jav a  2  s  . co m*/
 * @param xml
 */
private RequestTask(final String addr, String xml) {
    this.addr = addr;
    httpclient = new DefaultHttpClient();
    response = null;
    RequestLine line = new BasicRequestLine("POST", "/Freerider_backend/Servlet",
            new ProtocolVersion("HTTP", 1, 1));
    entityRequest = new BasicHttpEntityEnclosingRequest(line);
    try {

        entity = new ByteArrayEntity(xml.getBytes("ISO-8859-1"));
        entityRequest.setEntity(entity);
    } catch (UnsupportedEncodingException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
}

From source file:priv.test.wechat.HttpRequestBase.java

public RequestLine getRequestLine() {
    final String method = getMethod();
    final ProtocolVersion ver = getProtocolVersion();
    final URI uri = getURI();
    String uritext = null;/*from   w  ww .  ja  v  a  2 s  .c om*/
    if (uri != null) {
        uritext = uri.toASCIIString();
    }
    if (uritext == null || uritext.length() == 0) {
        uritext = "/";
    }
    return new BasicRequestLine(method, uritext, ver);
}

From source file:ste.web.http.api.RRequest.java

/**
 * //from   w  ww.ja v a  2  s .  c o m
 * @param uri - NOT NULL
 * @param body - MAY BE NULL
 * 
 * @throws URISyntaxException if the given request has an invalid URI
 * @throws IllegalArgumentException if request is null
 * 
 */
public RRequest(final String uri, final JSONObject body) throws URISyntaxException {
    this(new BasicRequestLine("POST", uri, HttpVersion.HTTP_1_1), body);
}

From source file:org.elasticsearch.client.FailureTrackingResponseListenerTests.java

private static Response mockResponse() {
    ProtocolVersion protocolVersion = new ProtocolVersion("HTTP", 1, 1);
    RequestLine requestLine = new BasicRequestLine("GET", "/", protocolVersion);
    StatusLine statusLine = new BasicStatusLine(protocolVersion, 200, "OK");
    HttpResponse httpResponse = new BasicHttpResponse(statusLine);
    return new Response(requestLine, new HttpHost("localhost", 9200), httpResponse);
}

From source file:org.apache.axis2.transport.http.CommonsHTTPTransportSenderTest.java

public void testInvokeWithAxisHttpResponseImpl() throws Exception {
    RequestLine line = new BasicRequestLine("", "", new ProtocolVersion("http", 1, 0));
    MockHTTPResponse httpResponse = new MockAxisHttpResponse(line);
    SOAPEnvelope envelope = getEnvelope();
    httpResponse = (MockAxisHttpResponse) configAndRun(httpResponse, (OutTransportInfo) httpResponse, null,
            getTransportSender());/*from ww  w. jav a  2s . com*/

    assertEquals("Not the expected Header value", "application/xml",
            httpResponse.getHeaders().get("Content-Type"));
    assertEquals("Not the expected Header value", "custom-value",
            httpResponse.getHeaders().get("Custom-header"));
    assertEquals("Not the expected body content", envelope.toString().replace("utf", "UTF"),
            new String(httpResponse.getByteArrayOutputStream().toByteArray()));
}

From source file:de.hshannover.f4.trust.iron.mapserver.communication.http.BasicAccessAuthenticationTest.java

private HttpRequest getHttpRequest(String user, String pass) {
    HttpRequestFactory factory = new DefaultHttpRequestFactory();
    HttpRequest req = null;//from  www  .  j a va2 s.  co m
    String base64 = new String(Base64.encodeBase64(user.concat(":").concat(pass).getBytes()));
    try {
        req = factory
                .newHttpRequest(new BasicRequestLine("POST", "https://localhost:8444/", HttpVersion.HTTP_1_1));
        req.addHeader("Accept-Encoding", "gzip,deflate");
        req.addHeader("Content-Type", "application/soap+xml;charset=UTF-8");
        req.addHeader("User-Agent", "IROND Testsuite/1.0");
        req.addHeader("Host", "localhost:8444");
        req.addHeader("Content-Length", "198");
        req.addHeader("Authorization", "Basic " + base64);
    } catch (MethodNotSupportedException e) {
        e.printStackTrace();
    }
    return req;
}

From source file:com.subgraph.vega.internal.http.proxy.VegaHttpRequestParser.java

@Override
public HttpMessage parse() throws IOException, HttpException {
    RequestLine requestLine;/*from  w  w  w . j  av a 2  s .c om*/
    try {
        requestLine = parseRequestLine(sessionBuffer);
    } catch (ParseException px) {
        throw new ProtocolException(px.getMessage(), px);
    }

    List<CharArrayBuffer> headerLines = new ArrayList<CharArrayBuffer>();
    Header[] headers = AbstractMessageParser.parseHeaders(sessionBuffer, maxHeaderCount, maxLineLen, lineParser,
            headerLines);

    if (conn.isSslConnection()) {
        URI uri;
        try {
            uri = new URI(requestLine.getUri());
        } catch (URISyntaxException e) {
            throw new ProtocolException("Invalid URI: " + requestLine.getUri(), e);
        }
        if (uri.getScheme() == null) {
            final Header hostHeader = getFirstHeader(headers, HTTP.TARGET_HOST);
            final StringBuilder buf = new StringBuilder();
            if (hostHeader != null) {
                // REVISIT: does using the Host header value instead of the SSL host risk opening another connection?
                buf.append("https://");
                buf.append(hostHeader.getValue());
            } else {
                buf.append(conn.getSslHost().toURI());
            }
            buf.append(uri.getRawPath());
            if (uri.getRawQuery() != null) {
                buf.append("?");
                buf.append(uri.getRawQuery());
            }

            requestLine = new BasicRequestLine(requestLine.getMethod(), buf.toString(),
                    requestLine.getProtocolVersion());
        }
    }

    HttpMessage message = requestFactory.newHttpRequest(requestLine);
    message.setHeaders(headers);
    return message;
}