@Override public HttpStatus handle(Channel ctx, boolean isKeepAlive, Req req) { HttpIO.INSTANCE.write200(HttpUtils.maybe(req), ctx, isKeepAlive, contentType, response); return HttpStatus.DONE; }
@Override public HttpStatus handle(Channel ctx, boolean isKeepAlive, Req req) { byte[] bytes = resource.getBytesOrNull(); if (bytes != null) { HttpIO.INSTANCE.write200(HttpUtils.maybe(req), ctx, isKeepAlive, contentType, bytes); return HttpStatus.DONE; } else { return HttpStatus.NOT_FOUND; } }
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 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 final HttpStatus handle(Channel ctx, boolean isKeepAlive, Req req) { Object result; MaybeReq maybeReq = HttpUtils.maybe(req);
@Override public HttpStatus handle(Channel ctx, boolean isKeepAlive, Req req) { if (!HttpUtils.isGetReq(req)) return HttpStatus.NOT_FOUND; try { String[] staticFilesLocations = customization.staticFilesPath(); if (!U.isEmpty(staticFilesLocations)) { Res res = HttpUtils.staticResource(req, staticFilesLocations); if (res != null) { StaticFilesSecurity staticFilesSecurity = customization.staticFilesSecurity(); if (staticFilesSecurity.canServe(req, res)) { byte[] bytes = res.getBytesOrNull(); if (bytes != null) { MediaType contentType = U.or(MediaType.getByFileName(res.getName()), MediaType.BINARY); HttpIO.INSTANCE.write200(HttpUtils.maybe(req), ctx, isKeepAlive, contentType, bytes); return HttpStatus.DONE; } } } } return HttpStatus.NOT_FOUND; } catch (Exception e) { return HttpIO.INSTANCE.errorAndDone(req, e, LogLevel.ERROR); } }
@Override public HttpStatus handle(Channel ctx, boolean isKeepAlive, Req req) { HttpIO.INSTANCE.write200(HttpUtils.maybe(req), ctx, isKeepAlive, contentType, response); return HttpStatus.DONE; }
@Override public HttpStatus handle(Channel ctx, boolean isKeepAlive, Req req) { byte[] bytes = resource.getBytesOrNull(); if (bytes != null) { HttpIO.INSTANCE.write200(HttpUtils.maybe(req), ctx, isKeepAlive, contentType, bytes); return HttpStatus.DONE; } else { return HttpStatus.NOT_FOUND; } }
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 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 final HttpStatus handle(Channel ctx, boolean isKeepAlive, Req req) { Object result; MaybeReq maybeReq = HttpUtils.maybe(req);
@Override public HttpStatus handle(Channel ctx, boolean isKeepAlive, Req req) { if (!HttpUtils.isGetReq(req)) return HttpStatus.NOT_FOUND; try { String[] staticFilesLocations = customization.staticFilesPath(); if (!U.isEmpty(staticFilesLocations)) { Res res = HttpUtils.staticResource(req, staticFilesLocations); if (res != null) { StaticFilesSecurity staticFilesSecurity = customization.staticFilesSecurity(); if (staticFilesSecurity.canServe(req, res)) { byte[] bytes = res.getBytesOrNull(); if (bytes != null) { MediaType contentType = U.or(MediaType.getByFileName(res.getName()), MediaType.BINARY); HttpIO.INSTANCE.write200(HttpUtils.maybe(req), ctx, isKeepAlive, contentType, bytes); return HttpStatus.DONE; } } } } return HttpStatus.NOT_FOUND; } catch (Exception e) { return HttpIO.INSTANCE.errorAndDone(req, e, LogLevel.ERROR); } }