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);
}
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);
}
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);
}
Aggregations