use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpResponse in project zuul by Netflix.
the class PushMessageSender method sendHttpResponse.
private void sendHttpResponse(ChannelHandlerContext ctx, FullHttpRequest request, HttpResponseStatus status, PushUserAuth userAuth) {
final FullHttpResponse resp = new DefaultFullHttpResponse(HTTP_1_1, status);
resp.headers().add("Content-Length", "0");
final ChannelFuture cf = ctx.channel().writeAndFlush(resp);
if (!HttpUtil.isKeepAlive(request)) {
cf.addListener(ChannelFutureListener.CLOSE);
}
logPushEvent(request, status, userAuth);
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpResponse in project wildfly by wildfly.
the class TestingOcspServer method getHttpResponse.
public HttpResponse getHttpResponse(HttpRequest request, HttpOcspServlet servlet) {
byte[] body;
HttpMethod method;
if (request.getBody() == null) {
method = HttpMethod.GET;
body = request.getPath().getValue().split("/ocsp/", 2)[1].getBytes(UTF_8);
} else {
method = HttpMethod.POST;
body = request.getBody().getRawBytes();
}
ByteBuf buffer = Unpooled.wrappedBuffer(body);
FullHttpRequest nettyRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_0, method, request.getPath().getValue(), buffer);
for (Header header : request.getHeaderList()) {
for (NottableString value : header.getValues()) {
nettyRequest.headers().add(header.getName().getValue(), value.getValue());
}
}
FullHttpResponse nettyResponse;
try {
nettyResponse = servlet.service(nettyRequest, new ServletURI(request.getPath().getValue()), null, SslReverseProxyMode.NONE);
} catch (Exception e) {
throw new RuntimeException(e);
}
HttpResponse response = response().withStatusCode(nettyResponse.status().code()).withBody(nettyResponse.content().array());
for (Map.Entry<String, String> header : nettyResponse.headers()) {
response.withHeader(header.getKey(), header.getValue());
}
return response;
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpResponse in project dubbo by alibaba.
the class HttpProcessHandler method channelRead0.
@Override
protected void channelRead0(ChannelHandlerContext ctx, HttpRequest msg) throws Exception {
CommandContext commandContext = HttpCommandDecoder.decode(msg);
// return 404 when fail to construct command context
FullHttpResponse response;
if (commandContext == null) {
log.warn("can not found commandContext url: " + msg.getUri());
response = http404();
} else {
commandContext.setRemote(ctx.channel());
try {
String result = commandExecutor.execute(commandContext);
response = http200(result);
} catch (NoSuchCommandException ex) {
log.error("can not find commandContext: " + commandContext, ex);
response = http404();
} catch (Exception qosEx) {
log.error("execute commandContext: " + commandContext + " got exception", qosEx);
response = http500(qosEx.getMessage());
}
}
ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE);
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpResponse in project blade by biezhi.
the class DefaultExceptionHandler method renderPage.
protected void renderPage(Response response, ModelAndView modelAndView) {
var sw = new StringWriter();
try {
WebContext.blade().templateEngine().render(modelAndView, sw);
ByteBuf buffer = Unpooled.wrappedBuffer(sw.toString().getBytes("utf-8"));
FullHttpResponse fullHttpResponse = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.valueOf(response.statusCode()), buffer);
response.body(new RawBody(fullHttpResponse));
} catch (Exception e) {
log.error("Render view error", e);
}
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpResponse in project traccar by tananaev.
the class Mta6ProtocolDecoder method sendContinue.
private void sendContinue(Channel channel) {
FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.CONTINUE);
channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress()));
}
Aggregations