private void renderResponse(int code, MediaType contentType, RespBody body) { rendering = true; completed = body != null; HttpIO.INSTANCE.respond( HttpUtils.maybe(this), channel, connId, handle, code, isKeepAlive, contentType, body, response != null ? response.headers() : null, response != null ? response.cookies() : null ); }
@Override public void onRequest(Channel channel, RapidoidHelper data) { boolean isKeepAlive = data.isKeepAlive.value; RespBody body = new RespBodyBytes("Not found!".getBytes()); HttpIO.INSTANCE.respond(HttpUtils.noReq(), channel, -1, -1, 404, isKeepAlive, MediaType.PLAIN_TEXT_UTF_8, body, null, null); channel.send().closeIf(!isKeepAlive); } }
private void serveCached(ReqImpl req, CachedResp resp) { Channel channel = req.channel(); req.cached(true); HttpIO.INSTANCE.respond(HttpUtils.req(req), channel, -1, -1, resp.statusCode, req.isKeepAlive(), resp.contentType, new RespBodyBuffer(resp.body.duplicate()), resp.headers, null); channel.send().closeIf(!req.isKeepAlive()); }
private void internalServerError(final Channel channel, final boolean isKeepAlive, final Req req) { MediaType contentType = req != null ? req.contentType() : HttpUtils.getDefaultContentType(); HttpResponseRenderer jsonRenderer = Customization.of(req).jsonResponseRenderer(); RespBody body = new RespBodyBytes(HttpUtils.responseToBytes(req, INTERNAL_SERVER_ERROR, contentType, jsonRenderer)); HttpIO.INSTANCE.respond(HttpUtils.maybe(req), channel, -1, -1, 500, isKeepAlive, contentType, body, null, null); }
@Override public void onRequest(Channel channel, RapidoidHelper data) { boolean isKeepAlive = data.isKeepAlive.value; RespBody body = new RespBodyBytes("Not found!".getBytes()); HttpIO.INSTANCE.respond(HttpUtils.noReq(), channel, -1, -1, 404, isKeepAlive, MediaType.PLAIN_TEXT_UTF_8, body, null, null); channel.send().closeIf(!isKeepAlive); } }
private void renderResponse(int code, MediaType contentType, RespBody body) { rendering = true; completed = body != null; HttpIO.INSTANCE.respond( HttpUtils.maybe(this), channel, connId, handle, code, isKeepAlive, contentType, body, response != null ? response.headers() : null, response != null ? response.cookies() : null ); }
private void serveCached(ReqImpl req, CachedResp resp) { Channel channel = req.channel(); req.cached(true); HttpIO.INSTANCE.respond(HttpUtils.req(req), channel, -1, -1, resp.statusCode, req.isKeepAlive(), resp.contentType, new RespBodyBuffer(resp.body.duplicate()), resp.headers, null); channel.send().closeIf(!req.isKeepAlive()); }
private void internalServerError(final Channel channel, final boolean isKeepAlive, final Req req) { MediaType contentType = req != null ? req.contentType() : HttpUtils.getDefaultContentType(); HttpResponseRenderer jsonRenderer = Customization.of(req).jsonResponseRenderer(); RespBody body = new RespBodyBytes(HttpUtils.responseToBytes(req, INTERNAL_SERVER_ERROR, contentType, jsonRenderer)); HttpIO.INSTANCE.respond(HttpUtils.maybe(req), channel, -1, -1, 500, isKeepAlive, contentType, body, null, null); }