Search in sources :

Example 11 with RequestLine

use of org.apache.http.RequestLine in project XobotOS by xamarin.

the class HttpRequestParser method parseHead.

protected HttpMessage parseHead(final SessionInputBuffer sessionBuffer) throws IOException, HttpException, ParseException {
    this.lineBuf.clear();
    int i = sessionBuffer.readLine(this.lineBuf);
    if (i == -1) {
        throw new ConnectionClosedException("Client closed connection");
    }
    ParserCursor cursor = new ParserCursor(0, this.lineBuf.length());
    RequestLine requestline = this.lineParser.parseRequestLine(this.lineBuf, cursor);
    return this.requestFactory.newHttpRequest(requestline);
}
Also used : ParserCursor(org.apache.http.message.ParserCursor) RequestLine(org.apache.http.RequestLine) ConnectionClosedException(org.apache.http.ConnectionClosedException)

Example 12 with RequestLine

use of org.apache.http.RequestLine in project cdap-ingest by caskdata.

the class StreamInfoHttpRequestHandler method handle.

@Override
public void handle(HttpRequest httpRequest, HttpResponse response, HttpContext httpContext) throws HttpException, IOException {
    RequestLine requestLine = httpRequest.getRequestLine();
    String method = requestLine.getMethod();
    int statusCode;
    if (!HttpMethod.GET.equals(method)) {
        statusCode = HttpStatus.SC_NOT_IMPLEMENTED;
    } else {
        String uri = requestLine.getUri();
        String streamName = TestUtils.getStreamNameFromUri(uri);
        if (TestUtils.AUTH_STREAM_NAME.equals(streamName)) {
            statusCode = TestUtils.authorize(httpRequest);
        } else if (streamName.contains(TestUtils.WRITER_TEST_STREAM_NAME_POSTFIX)) {
            statusCode = HttpStatus.SC_OK;
        } else {
            statusCode = TestUtils.getStatusCodeByStreamName(streamName);
        }
        if (statusCode == HttpStatus.SC_OK) {
            StringEntity entity = new StringEntity("{\"partitionDuration\":3600000,\"indexInterval\":10000,\"ttl\":" + RestTest.STREAM_TTL + "}");
            entity.setContentType(MediaType.APPLICATION_JSON);
            response.setEntity(entity);
        }
    }
    response.setStatusCode(statusCode);
}
Also used : RequestLine(org.apache.http.RequestLine) StringEntity(org.apache.http.entity.StringEntity)

Example 13 with RequestLine

use of org.apache.http.RequestLine in project cdap-ingest by caskdata.

the class StreamTruncateHttpRequestHandler method handle.

@Override
public void handle(HttpRequest httpRequest, HttpResponse response, HttpContext httpContext) throws HttpException, IOException {
    RequestLine requestLine = httpRequest.getRequestLine();
    String method = requestLine.getMethod();
    int statusCode;
    if (!HttpMethod.POST.equals(method)) {
        statusCode = HttpStatus.SC_NOT_IMPLEMENTED;
    } else {
        String uri = requestLine.getUri();
        String streamName = TestUtils.getStreamNameFromUri(uri);
        if (TestUtils.AUTH_STREAM_NAME.equals(streamName)) {
            statusCode = TestUtils.authorize(httpRequest);
        } else {
            statusCode = TestUtils.getStatusCodeByStreamName(streamName);
        }
    }
    response.setStatusCode(statusCode);
}
Also used : RequestLine(org.apache.http.RequestLine)

Aggregations

RequestLine (org.apache.http.RequestLine)13 HttpEntity (org.apache.http.HttpEntity)5 HttpHost (org.apache.http.HttpHost)4 HttpResponse (org.apache.http.HttpResponse)4 ProtocolVersion (org.apache.http.ProtocolVersion)4 StatusLine (org.apache.http.StatusLine)4 BasicHttpResponse (org.apache.http.message.BasicHttpResponse)4 BasicRequestLine (org.apache.http.message.BasicRequestLine)4 BasicStatusLine (org.apache.http.message.BasicStatusLine)4 ConnectionClosedException (org.apache.http.ConnectionClosedException)3 Header (org.apache.http.Header)3 StringEntity (org.apache.http.entity.StringEntity)3 ParserCursor (org.apache.http.message.ParserCursor)3 IOException (java.io.IOException)2 BasicHttpEntityEnclosingRequest (org.apache.http.message.BasicHttpEntityEnclosingRequest)2 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1 JsonObject (com.google.gson.JsonObject)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 SocketTimeoutException (java.net.SocketTimeoutException)1 URL (java.net.URL)1