private static BadMessageException buildPrematureEofException(String format, Throwable cause) { return new BadMessageException(400, "Premature end of " + format + " data", cause); } }
private static BadMessageException buildBadDataException(String format, Throwable cause) { return new BadMessageException(400, "Invalid " + format + " data in request", cause); }
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); } }
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); } }
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"); }
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(); }
throw new BadMessageException("Bad EOL"); case COLON: if (_cr) throw new BadMessageException("Bad EOL"); break;
throw new BadMessageException("Bad EOL"); case COLON: if (_cr) throw new BadMessageException("Bad EOL"); break;
throw new BadMessageException("Bad EOL"); case COLON: if (_cr) throw new BadMessageException("Bad EOL"); break;
private byte next(ByteBuffer buffer) { byte ch = buffer.get(); CharState s = __charState[0xff & ch]; switch(s) { case ILLEGAL: throw new IllegalCharacterException(_state,ch,buffer); case LF: _cr=false; break; case CR: if (_cr) throw new BadMessageException("Bad EOL"); _cr=true; if (buffer.hasRemaining()) { if(_maxHeaderBytes>0 && _state.ordinal()<State.END.ordinal()) _headerBytes++; return next(buffer); } // Can return 0 here to indicate the need for more characters, // because a real 0 in the buffer would cause a BadMessage below return 0; case LEGAL: if (_cr) throw new BadMessageException("Bad EOL"); } return ch; }
public boolean upgrade(Request request) { if (HttpMethod.PRI.is(request.getMethod())) { getParser().directUpgrade(); } else { HttpField settingsField = request.getFields().getField(HttpHeader.HTTP2_SETTINGS); if (settingsField == null) throw new BadMessageException("Missing " + HttpHeader.HTTP2_SETTINGS + " header"); String value = settingsField.getValue(); final byte[] settings = B64Code.decodeRFC4648URL(value == null ? "" : value); if (LOG.isDebugEnabled()) LOG.debug("{} settings {}",this,TypeUtil.toHexString(settings)); SettingsFrame settingsFrame = SettingsBodyParser.parseBody(BufferUtil.toBuffer(settings)); if (settingsFrame == null) { LOG.warn("Invalid {} header value: {}", HttpHeader.HTTP2_SETTINGS, value); throw new BadMessageException(); } getParser().standardUpgrade(); upgradeFrames.add(new PrefaceFrame()); upgradeFrames.add(settingsFrame); // Remember the request to send a response from onOpen(). upgradeFrames.add(new HeadersFrame(1, new Request(request), null, true)); } return true; }
public Runnable onPushRequest(MetaData.Request request) { try { onRequest(request); getRequest().setAttribute("org.eclipse.jetty.pushed", Boolean.TRUE); onContentComplete(); onRequestComplete(); if (LOG.isDebugEnabled()) { Stream stream = getStream(); LOG.debug("HTTP2 PUSH Request #{}/{}:{}{} {} {}{}{}", stream.getId(), Integer.toHexString(stream.getSession().hashCode()), System.lineSeparator(), request.getMethod(), request.getURI(), request.getHttpVersion(), System.lineSeparator(), request.getFields()); } return this; } catch (BadMessageException x) { onBadMessage(x); return null; } catch (Throwable x) { onBadMessage(new BadMessageException(HttpStatus.INTERNAL_SERVER_ERROR_500, null, x)); return null; } }
throw new BadMessageException(400,"Bad URI");
throw new BadMessageException(HttpStatus.NOT_IMPLEMENTED_501,"Unsupported Content-Encoding");