use of org.jboss.netty.handler.codec.http.HttpHeaders in project druid by druid-io.
the class ResponseCookieHandler method handleResponse.
@Override
public ClientResponse<Intermediate> handleResponse(HttpResponse httpResponse) {
try {
final HttpHeaders headers = httpResponse.headers();
manager.put(uri, Maps.asMap(headers.names(), new Function<String, List<String>>() {
@Override
public List<String> apply(String input) {
return headers.getAll(input);
}
}));
} catch (IOException e) {
log.error(e, "Error while processing Cookies from header");
} finally {
return delegate.handleResponse(httpResponse);
}
}
use of org.jboss.netty.handler.codec.http.HttpHeaders in project graylog2-server by Graylog2.
the class HttpTransportHandlerTest method messageReceivedSuccessfullyProcessesPOSTRequest.
@Test
public void messageReceivedSuccessfullyProcessesPOSTRequest() throws Exception {
final HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/gelf");
httpRequest.headers().add("Host", "localhost");
httpRequest.headers().add("Origin", "http://example.com");
httpRequest.headers().add("Connection", "close");
final String gelfMessage = "{\"version\":\"1.1\",\"short_message\":\"Foo\",\"host\":\"localhost\"}";
httpRequest.setContent(ChannelBuffers.copiedBuffer(gelfMessage.toCharArray(), StandardCharsets.UTF_8));
channel.offer(httpRequest);
channel.finish();
final HttpResponse httpResponse = channel.poll();
assertThat(httpResponse.getStatus()).isEqualTo(HttpResponseStatus.ACCEPTED);
final HttpHeaders headers = httpResponse.headers();
assertThat(headers.get(HttpHeaders.Names.CONTENT_LENGTH)).isEqualTo("0");
assertThat(headers.get(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_ORIGIN)).isEqualTo("http://example.com");
assertThat(headers.get(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_CREDENTIALS)).isEqualTo("true");
assertThat(headers.get(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_HEADERS)).isEqualTo("Authorization, Content-Type");
}
use of org.jboss.netty.handler.codec.http.HttpHeaders in project hive by apache.
the class ResponseCookieHandler method handleResponse.
@Override
public ClientResponse<Intermediate> handleResponse(HttpResponse httpResponse) {
try {
final HttpHeaders headers = httpResponse.headers();
manager.put(uri, Maps.asMap(headers.names(), input -> headers.getAll(input)));
} catch (IOException e) {
log.error("Error while processing Cookies from header", e);
} finally {
return delegate.handleResponse(httpResponse);
}
}
use of org.jboss.netty.handler.codec.http.HttpHeaders in project hive by apache.
the class ResponseCookieHandler method handleResponse.
@Override
public ClientResponse<Intermediate> handleResponse(HttpResponse httpResponse, TrafficCop trafficCop) {
try {
final HttpHeaders headers = httpResponse.headers();
manager.put(uri, Maps.asMap(headers.names(), headers::getAll));
return delegate.handleResponse(httpResponse, trafficCop);
} catch (IOException e) {
LOG.error("Error while processing Cookies from header", e);
throw new RuntimeException(e);
}
}
use of org.jboss.netty.handler.codec.http.HttpHeaders in project graylog2-server by Graylog2.
the class HttpTransportHandlerTest method messageReceivedReturns404ForWrongPath.
@Test
public void messageReceivedReturns404ForWrongPath() throws Exception {
final HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/");
httpRequest.headers().add("Host", "localhost");
httpRequest.headers().add("Origin", "http://example.com");
httpRequest.headers().add("Connection", "close");
channel.offer(httpRequest);
channel.finish();
final HttpResponse httpResponse = channel.poll();
assertThat(httpResponse.getStatus()).isEqualTo(HttpResponseStatus.NOT_FOUND);
final HttpHeaders headers = httpResponse.headers();
assertThat(headers.get(HttpHeaders.Names.CONTENT_LENGTH)).isEqualTo("0");
assertThat(headers.get(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_ORIGIN)).isEqualTo("http://example.com");
assertThat(headers.get(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_CREDENTIALS)).isEqualTo("true");
assertThat(headers.get(HttpHeaders.Names.ACCESS_CONTROL_ALLOW_HEADERS)).isEqualTo("Authorization, Content-Type");
}
Aggregations