private static BadMessageException buildPrematureEofException(String format, Throwable cause) { return new BadMessageException(400, "Premature end of " + format + " data", cause); } }
public void onBadMessage(BadMessageException failure) int status = failure.getCode(); String reason = failure.getReason(); if (status < 400 || status > 599) failure = new BadMessageException(HttpStatus.BAD_REQUEST_400, reason, failure);
Throwable cause = e.getCause(); boolean stack = LOG.isDebugEnabled() || (!(cause instanceof NumberFormatException ) && (cause instanceof RuntimeException || cause instanceof Error)); LOG.warn("bad HTTP parsed: "+e._code+(e.getReason()!=null?" "+e.getReason():"")+" for "+_handler,e); else LOG.warn("bad HTTP parsed: "+e._code+(e.getReason()!=null?" "+e.getReason():"")+" for "+_handler); setState(State.CLOSE); _handler.badMessage(e.getCode(), e.getReason());
private void minimalErrorResponse(Throwable failure) { try { int code = 500; Integer status=(Integer)_request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); if (status!=null) code = status.intValue(); else { Throwable cause = unwrap(failure,BadMessageException.class); if (cause instanceof BadMessageException) code = ((BadMessageException)cause).getCode(); } _response.reset(true); _response.setStatus(code); _response.flushBuffer(); } catch (Throwable x) { if (x != failure) failure.addSuppressed(x); abort(failure); } }
private static BadMessageException buildBadDataException(String format, Throwable cause) { return new BadMessageException(400, "Invalid " + format + " data in request", cause); }
@Override public void badMessage(BadMessageException failure) { HttpExchange exchange = getHttpExchange(); if (exchange != null) { HttpResponse response = exchange.getResponse(); response.status(failure.getCode()).reason(failure.getReason()); failAndClose(new HttpResponseException("HTTP protocol violation: bad response on " + getHttpConnection(), response, failure)); } }
private static BadMessageException buildBadDataException(String format, Throwable cause) { return new BadMessageException(400, "Invalid " + format + " data in request", cause); }
private static BadMessageException buildPrematureEofException(String format, Throwable cause) { return new BadMessageException(400, "Premature end of " + format + " data", cause); } }
protected HostPortHttpField(HttpHeader header, String name, String authority) { super(header,name,authority); try { _hostPort=new HostPort(authority); } catch(Exception e) { throw new BadMessageException(HttpStatus.BAD_REQUEST_400,"Bad HostPort",e); } }
private long convertContentLength(String valueString) { try { return Long.parseLong(valueString); } catch(NumberFormatException e) { LOG.ignore(e); throw new BadMessageException(HttpStatus.BAD_REQUEST_400,"Invalid Content-Length Value",e); } }
private void checkVersion() { if (_version==null) throw new BadMessageException(HttpStatus.BAD_REQUEST_400,"Unknown Version"); if (_version.getVersion()<10 || _version.getVersion()>20) throw new BadMessageException(HttpStatus.BAD_REQUEST_400,"Bad Version"); }
protected HostPortHttpField(HttpHeader header, String name, String authority) { super(header,name,authority); try { _hostPort=new HostPort(authority); } catch(Exception e) { throw new BadMessageException(HttpStatus.BAD_REQUEST_400,"Bad HostPort",e); } }
private void checkVersion() { if (_version==null) throw new BadMessageException(HttpStatus.BAD_REQUEST_400,"Unknown Version"); if (_version.getVersion()<10 || _version.getVersion()>20) throw new BadMessageException(HttpStatus.BAD_REQUEST_400,"Bad Version"); }
private long convertContentLength(String valueString) { try { return Long.parseLong(valueString); } catch(NumberFormatException e) { LOG.ignore(e); throw new BadMessageException(HttpStatus.BAD_REQUEST_400,"Invalid Content-Length Value"); } }
private long convertContentLength(String valueString) { try { return Long.parseLong(valueString); } catch(NumberFormatException e) { LOG.ignore(e); throw new BadMessageException(HttpStatus.BAD_REQUEST_400,"Invalid Content-Length Value"); } }
private String getProxyField(ByteBuffer buffer) { _string.setLength(0); _length=0; while (buffer.hasRemaining()) { // process each character byte ch=next(buffer); if (ch<=' ') return _string.toString(); _string.append((char)ch); } throw new BadMessageException(); }