public ServerParser(ByteBufferPool byteBufferPool, Listener listener, int maxDynamicTableSize, int maxHeaderSize) { super(byteBufferPool, listener, maxDynamicTableSize, maxHeaderSize); this.listener = listener; this.prefaceParser = new PrefaceParser(listener); }
/** * <p>A direct upgrade is an unofficial upgrade from HTTP/1.1 to HTTP/2.0.</p> * <p>A direct upgrade is initiated when {@code org.eclipse.jetty.server.HttpConnection} * sees a request with these bytes:</p> * <pre> * PRI * HTTP/2.0\r\n * \r\n * </pre> * <p>This request is part of the HTTP/2.0 preface, indicating that a * HTTP/2.0 client is attempting a h2c direct connection.</p> * <p>This is not a standard HTTP/1.1 Upgrade path.</p> */ public void directUpgrade() { if (state != State.PREFACE) throw new IllegalStateException(); prefaceParser.directUpgrade(); }
public boolean parse(ByteBuffer buffer) { while (buffer.hasRemaining()) { int currByte = buffer.get(); if (currByte != PrefaceFrame.PREFACE_BYTES[cursor]) { BufferUtil.clear(buffer); notifyConnectionFailure(ErrorCode.PROTOCOL_ERROR.code, "invalid_preface"); return false; } ++cursor; if (cursor == PrefaceFrame.PREFACE_BYTES.length) { cursor = 0; if (LOG.isDebugEnabled()) LOG.debug("Parsed preface bytes from {}", buffer); return true; } } return false; }
if (!prefaceParser.parse(buffer)) return; if (notifyPreface)
public boolean parse(ByteBuffer buffer) { while (buffer.hasRemaining()) { int currByte = buffer.get(); if (currByte != PrefaceFrame.PREFACE_BYTES[cursor]) { BufferUtil.clear(buffer); notifyConnectionFailure(ErrorCode.PROTOCOL_ERROR.code, "invalid_preface"); return false; } ++cursor; if (cursor == PrefaceFrame.PREFACE_BYTES.length) { cursor = 0; if (LOG.isDebugEnabled()) LOG.debug("Parsed preface bytes from {}", buffer); return true; } } return false; }
if (!prefaceParser.parse(buffer)) return; if (notifyPreface)
public ServerParser(ByteBufferPool byteBufferPool, Listener listener, int maxDynamicTableSize, int maxHeaderSize) { super(byteBufferPool, listener, maxDynamicTableSize, maxHeaderSize); this.listener = listener; this.prefaceParser = new PrefaceParser(listener); }
/** * <p>A direct upgrade is an unofficial upgrade from HTTP/1.1 to HTTP/2.0.</p> * <p>A direct upgrade is initiated when {@code org.eclipse.jetty.server.HttpConnection} * sees a request with these bytes:</p> * <pre> * PRI * HTTP/2.0\r\n * \r\n * </pre> * <p>This request is part of the HTTP/2.0 preface, indicating that a * HTTP/2.0 client is attempting a h2c direct connection.</p> * <p>This is not a standard HTTP/1.1 Upgrade path.</p> */ public void directUpgrade() { if (state != State.PREFACE) throw new IllegalStateException(); prefaceParser.directUpgrade(); }