private void handleError(Throwable error, final Req req, final Resp resp, final ProxyMapping mapping, final int attempts, final long since) { if (error instanceof ConnectException || error instanceof IOException) { if (HttpUtils.isGetReq(req) && !U.timedOut(since, timeout())) { Jobs.after(retryDelay()).milliseconds(() -> process(req, resp, mapping, attempts + 1, since)); } else { HttpIO.INSTANCE.errorAndDone(req, U.rte("Couldn't connect to the upstream!", error), LogLevel.DEBUG); } } else { HttpIO.INSTANCE.errorAndDone(req, error, LogLevel.ERROR); } }
private boolean handleError(Channel channel, boolean isKeepAlive, Req req, Throwable e) { if (req != null) { if (!((ReqImpl) req).isStopped()) { try { HttpIO.INSTANCE.errorAndDone(req, e, LogLevel.ERROR); } catch (Exception e1) { Log.error("HTTP error handler error!", e1); internalServerError(channel, isKeepAlive, req); } } return true; } else { Log.error("Low-level HTTP handler error!", e); internalServerError(channel, isKeepAlive, null); } return false; }
@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); } }
private void handleError(Throwable error, final Req req, final Resp resp, final ProxyMapping mapping, final int attempts, final long since) { if (error instanceof ConnectException || error instanceof IOException) { if (HttpUtils.isGetReq(req) && !Msc.timedOut(since, timeout())) { Jobs.after(retryDelay()).milliseconds(new Runnable() { @Override public void run() { process(req, resp, mapping, attempts + 1, since); } }); } else { HttpIO.INSTANCE.errorAndDone(req, U.rte("Couldn't connect to the upstream!", error), LogLevel.DEBUG); } } else { HttpIO.INSTANCE.errorAndDone(req, error, LogLevel.ERROR); } }
private boolean handleError(Channel channel, boolean isKeepAlive, Req req, Throwable e) { if (req != null) { if (!((ReqImpl) req).isStopped()) { try { HttpIO.INSTANCE.errorAndDone(req, e, LogLevel.ERROR); } catch (Exception e1) { Log.error("HTTP error handler error!", e1); internalServerError(channel, isKeepAlive, req); } } return true; } else { Log.error("Low-level HTTP handler error!", e); internalServerError(channel, isKeepAlive, null); } return false; }
@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); } }