use of org.jboss.netty.handler.codec.http.HttpRequest in project databus by linkedin.
the class HttpRequestLoggingHandler method messageReceived.
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception {
if (e.getMessage() instanceof HttpRequest) {
// HttpRequest is for a relay from client/bootstrap, hence it is an inbound request
// ( outbound = false )
HttpRequest req = (HttpRequest) e.getMessage();
startHttpRequest(false, req);
} else if (e.getMessage() instanceof HttpResponse) {
// HttpResponse is from a relay to a client/bootstrap, hence it is an outbound request
// ( outbound = true )
HttpResponse resp = (HttpResponse) e.getMessage();
startHttpResponse(true, resp);
} else if (e.getMessage() instanceof HttpChunk) {
HttpChunk chunk = (HttpChunk) e.getMessage();
processHttpChunk(true, chunk);
if (State.OUTBOUND_RESPONSE_END == _state) {
endHttpResponse(true);
}
}
super.messageReceived(ctx, e);
}
use of org.jboss.netty.handler.codec.http.HttpRequest in project databus by linkedin.
the class BootstrapStartScnHttpResponseProcessor method onTargetScnConnectSuccess.
void onTargetScnConnectSuccess() {
_curState = State.TARGET_SCN_REQUEST_WRITE;
ChannelPipeline channelPipeline = _channel.getPipeline();
_readTimeOutHandler = (ExtendedReadTimeoutHandler) channelPipeline.get(GenericHttpClientPipelineFactory.READ_TIMEOUT_HANDLER_NAME);
_readTimeOutHandler.start(channelPipeline.getContext(_readTimeOutHandler));
BootstrapTargetScnHttpResponseProcessor targetResponseProcessor = new BootstrapTargetScnHttpResponseProcessor(this, _callback, _callbackStateReuse, _checkpoint, _remoteExceptionHandler, _readTimeOutHandler);
final String url = createTargetScnRequestUrl();
LOG.info("Sending " + url);
// Prepare the HTTP request.
HttpRequest request = createEmptyRequest(url);
sendRequest(request, new TargetScnRequestResultListener(), targetResponseProcessor);
}
use of org.jboss.netty.handler.codec.http.HttpRequest in project databus by linkedin.
the class StreamHttpResponseProcessor method onStreamConnectSuccess.
void onStreamConnectSuccess() {
boolean debugEnabled = LOG.isDebugEnabled();
_curState = State.STREAM_REQUEST_WRITE;
ChannelPipeline channelPipeline = _channel.getPipeline();
_readTimeOutHandler = (ExtendedReadTimeoutHandler) channelPipeline.get(GenericHttpClientPipelineFactory.READ_TIMEOUT_HANDLER_NAME);
_readTimeOutHandler.start(channelPipeline.getContext(_readTimeOutHandler));
StreamHttpResponseProcessor streamResponseProcessor = new StreamHttpResponseProcessor(this, _callback, _callbackStateReuse, _readTimeOutHandler);
StringBuilder uriString = new StringBuilder(1024);
boolean error = populateStreamRequestUrl(uriString);
if (error) {
return;
}
final String url = uriString.toString();
if (debugEnabled)
LOG.debug("Sending " + url);
// Prepare the HTTP request.
HttpRequest request = createEmptyRequest(url);
sendRequest(request, new StreamRequestResultListener(), streamResponseProcessor);
}
use of org.jboss.netty.handler.codec.http.HttpRequest in project voldemort by voldemort.
the class AbstractRestRequestHandler method messageReceived.
@Override
public void messageReceived(ChannelHandlerContext ctx, MessageEvent messageEvent) throws Exception {
RestRequestValidator requestValidator;
if (!readingChunks) {
// Construct the Request from messageEvent
HttpRequest request = this.request = (HttpRequest) messageEvent.getMessage();
String requestURI = this.request.getUri();
if (logger.isDebugEnabled()) {
logger.debug("Request URI: " + requestURI);
}
if (request.isChunked()) {
readingChunks = true;
} else {
// Instantiate the appropriate error handler
HttpMethod httpMethod = request.getMethod();
if (httpMethod.equals(HttpMethod.GET)) {
if (logger.isDebugEnabled()) {
logger.debug("Received a Http GET request at " + System.currentTimeMillis() + " ms");
}
requestValidator = new RestGetRequestValidator(request, messageEvent);
} else if (httpMethod.equals(HttpMethod.POST)) {
if (logger.isDebugEnabled()) {
logger.debug("Received a Http POST request at " + System.currentTimeMillis() + " ms");
}
requestValidator = new RestPutRequestValidator(request, messageEvent, this.isVectorClockOptional);
} else if (httpMethod.equals(HttpMethod.DELETE)) {
if (logger.isDebugEnabled()) {
logger.debug("Received a Http DELETE request at " + System.currentTimeMillis() + " ms");
}
requestValidator = new RestDeleteRequestValidator(request, messageEvent, this.isVectorClockOptional);
} else {
String errorMessage = "Illegal Http request received at " + System.currentTimeMillis() + " ms";
logger.error(errorMessage);
RestErrorHandler.writeErrorResponse(messageEvent, BAD_REQUEST, errorMessage);
return;
}
registerRequest(requestValidator, ctx, messageEvent);
}
} else {
HttpChunk chunk = (HttpChunk) messageEvent.getMessage();
if (chunk.isLast()) {
readingChunks = false;
}
}
}
use of org.jboss.netty.handler.codec.http.HttpRequest in project opentsdb by OpenTSDB.
the class TestHttpQuery method getContentBadEncoding.
@Test
public void getContentBadEncoding() {
final Channel channelMock = NettyMocks.fakeChannel();
final HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/");
final ChannelBuffer buf = ChannelBuffers.copiedBuffer("S\u00ED Se\u00F1or", CharsetUtil.ISO_8859_1);
req.setContent(buf);
final HttpQuery query = new HttpQuery(tsdb, req, channelMock);
assertThat("S\u00ED Se\u00F1or", not(equalTo(query.getContent())));
}
Aggregations