Class HttpParser
- java.lang.Object
-
- org.eclipse.jetty.http.HttpParser
-
@Deprecated(since="2021-05-27") public class HttpParser extends java.lang.ObjectDeprecated.The Eclipse Jetty and Apache Felix Http Jetty packages are no longer supported.A Parser for 1.0 and 1.1 as defined by RFC7230This parser parses HTTP client and server messages from buffers passed in the
parseNext(ByteBuffer)method. The parsed elements of the HTTP message are passed as event calls to theHttpParser.HttpHandlerinstance the parser is constructed with. If the passed handler is aHttpParser.RequestHandlerthen server side parsing is performed and if it is aHttpParser.ResponseHandler, then client side parsing is done.The contract of the
HttpParser.HttpHandlerAPI is that if a call returns true then the call toparseNext(ByteBuffer)will return as soon as possible also with a true response. Typically this indicates that the parsing has reached a stage where the caller should process the events accumulated by the handler. It is the preferred calling style that handling such as calling a servlet to process a request, should be done after a true return fromparseNext(ByteBuffer)rather than from within the scope of a call likeHttpParser.HttpHandler.messageComplete()For performance, the parse is heavily dependent on the
Trie.getBest(ByteBuffer, int, int)method to look ahead in a single pass for both the structure ( : and CRLF ) and semantic (which header and value) of a header. Specifically the staticHttpHeader.CACHEis used to lookup common combinations of headers and values (eg. "Connection: close"), or just header names (eg. "Connection:" ). For headers who's value is not known statically (eg. Host, COOKIE) then a per parser dynamic Trie ofHttpFieldsfrom previous parsed messages is used to help the parsing of subsequent messages.The parser can work in varying compliance modes:
- RFC7230
- (default) Compliance with RFC7230
- RFC2616
- Wrapped headers and HTTP/0.9 supported
- LEGACY
- (aka STRICT) Adherence to Servlet Specification requirement for exact case of header names, bypassing the header caches, which are case insensitive, otherwise equivalent to RFC2616
- See Also:
- RFC 7230
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceHttpParser.ComplianceHandlerDeprecated.static classHttpParser.FieldStateDeprecated.static interfaceHttpParser.HttpHandlerDeprecated.static interfaceHttpParser.RequestHandlerDeprecated.static interfaceHttpParser.ResponseHandlerDeprecated.static classHttpParser.StateDeprecated.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String__STRICTDeprecated.static Trie<HttpField>CACHEDeprecated.Cache of commonHttpFields including: Common static combinations such as: Connection: close Accept-Encoding: gzip Content-Length: 0 Combinations of Content-Type header for common mime types by common charsets Most common headers with null values so that a lookup will at least determine the header name even if the name:value combination is not cachedstatic intINITIAL_URI_LENGTHDeprecated.static LoggerLOGDeprecated.
-
Constructor Summary
Constructors Constructor Description HttpParser(HttpParser.RequestHandler handler)Deprecated.HttpParser(HttpParser.RequestHandler handler, int maxHeaderBytes)Deprecated.HttpParser(HttpParser.RequestHandler handler, int maxHeaderBytes, boolean strict)Deprecated.HttpParser(HttpParser.RequestHandler handler, int maxHeaderBytes, HttpCompliance compliance)Deprecated.HttpParser(HttpParser.RequestHandler handler, HttpCompliance compliance)Deprecated.HttpParser(HttpParser.ResponseHandler handler)Deprecated.HttpParser(HttpParser.ResponseHandler handler, int maxHeaderBytes)Deprecated.HttpParser(HttpParser.ResponseHandler handler, int maxHeaderBytes, boolean strict)Deprecated.HttpParser(HttpParser.ResponseHandler handler, int maxHeaderBytes, HttpCompliance compliance)Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidatEOF()Deprecated.Signal that the associated data source is at EOFvoidclose()Deprecated.Request that the associated data source be closedlonggetContentLength()Deprecated.longgetContentRead()Deprecated.Trie<HttpField>getFieldCache()Deprecated.HttpParser.HttpHandlergetHandler()Deprecated.intgetHeaderLength()Deprecated.HttpCompliancegetHttpCompliance()Deprecated.HttpParser.StategetState()Deprecated.booleaninContentState()Deprecated.booleaninHeaderState()Deprecated.booleanisAtEOF()Deprecated.booleanisChunking()Deprecated.booleanisClose()Deprecated.booleanisClosed()Deprecated.booleanisComplete()Deprecated.booleanisIdle()Deprecated.booleanisStart()Deprecated.booleanisState(HttpParser.State state)Deprecated.booleanisTerminated()Deprecated.booleanparseNext(java.nio.ByteBuffer buffer)Deprecated.Parse until next Event.voidreset()Deprecated.voidsetHeadResponse(boolean head)Deprecated.Set if a HEAD response is expectedjava.lang.StringtoString()Deprecated.
-
-
-
Field Detail
-
LOG
public static final Logger LOG
Deprecated.
-
__STRICT
@Deprecated public static final java.lang.String __STRICT
Deprecated.- See Also:
- Constant Field Values
-
INITIAL_URI_LENGTH
public static final int INITIAL_URI_LENGTH
Deprecated.- See Also:
- Constant Field Values
-
CACHE
public static final Trie<HttpField> CACHE
Deprecated.Cache of commonHttpFields including:- Common static combinations such as:
- Connection: close
- Accept-Encoding: gzip
- Content-Length: 0
- Combinations of Content-Type header for common mime types by common charsets
- Most common headers with null values so that a lookup will at least determine the header name even if the name:value combination is not cached
- Common static combinations such as:
-
-
Constructor Detail
-
HttpParser
public HttpParser(HttpParser.RequestHandler handler)
Deprecated.
-
HttpParser
public HttpParser(HttpParser.ResponseHandler handler)
Deprecated.
-
HttpParser
public HttpParser(HttpParser.RequestHandler handler, int maxHeaderBytes)
Deprecated.
-
HttpParser
public HttpParser(HttpParser.ResponseHandler handler, int maxHeaderBytes)
Deprecated.
-
HttpParser
@Deprecated public HttpParser(HttpParser.RequestHandler handler, int maxHeaderBytes, boolean strict)
Deprecated.
-
HttpParser
@Deprecated public HttpParser(HttpParser.ResponseHandler handler, int maxHeaderBytes, boolean strict)
Deprecated.
-
HttpParser
public HttpParser(HttpParser.RequestHandler handler, HttpCompliance compliance)
Deprecated.
-
HttpParser
public HttpParser(HttpParser.RequestHandler handler, int maxHeaderBytes, HttpCompliance compliance)
Deprecated.
-
HttpParser
public HttpParser(HttpParser.ResponseHandler handler, int maxHeaderBytes, HttpCompliance compliance)
Deprecated.
-
-
Method Detail
-
getHandler
public HttpParser.HttpHandler getHandler()
Deprecated.
-
getHttpCompliance
public HttpCompliance getHttpCompliance()
Deprecated.
-
getContentLength
public long getContentLength()
Deprecated.
-
getContentRead
public long getContentRead()
Deprecated.
-
getHeaderLength
public int getHeaderLength()
Deprecated.
-
setHeadResponse
public void setHeadResponse(boolean head)
Deprecated.Set if a HEAD response is expected- Parameters:
head- true if head response is expected
-
getState
public HttpParser.State getState()
Deprecated.
-
inContentState
public boolean inContentState()
Deprecated.
-
inHeaderState
public boolean inHeaderState()
Deprecated.
-
isChunking
public boolean isChunking()
Deprecated.
-
isStart
public boolean isStart()
Deprecated.
-
isClose
public boolean isClose()
Deprecated.
-
isClosed
public boolean isClosed()
Deprecated.
-
isIdle
public boolean isIdle()
Deprecated.
-
isComplete
public boolean isComplete()
Deprecated.
-
isTerminated
public boolean isTerminated()
Deprecated.
-
isState
public boolean isState(HttpParser.State state)
Deprecated.
-
parseNext
public boolean parseNext(java.nio.ByteBuffer buffer)
Deprecated.Parse until next Event.- Parameters:
buffer- the buffer to parse- Returns:
- True if an
HttpParser.RequestHandlermethod was called and it returned true;
-
isAtEOF
public boolean isAtEOF()
Deprecated.
-
atEOF
public void atEOF()
Deprecated.Signal that the associated data source is at EOF
-
close
public void close()
Deprecated.Request that the associated data source be closed
-
reset
public void reset()
Deprecated.
-
toString
public java.lang.String toString()
Deprecated.- Overrides:
toStringin classjava.lang.Object
-
-