# README
httpsp
This go modules provides HTTP message "stream"/stateful parsing functions. (work in progress)
It supports parsing partial HTTP messages received on streams: if the parsing functions detect an incomplete message, they will signal this through the return values and parsing can be latter resumed from the point where it stopped.
# Functions
GetHdrType returns the corresponding HdrT type for a given header name.
GetMethodNo converts from an ASCII SIP method name to the corresponding numeric internal value.
GetPField returns a byte slice for the corresponding field f, pointing inside buf.
ParseAllTrEncValues tries to parse all the values in a Transfer-Encoding header situated at offs in buf and adds them to the passed PTrEnc values.
ParseAllUpgradeValues tries to parse all the values in an Upgrade header situated at offs in buf and adds them to the passed PUpgrade values.
ParseAllWSExtValues tries to parse all the values in a Sec-WebSocket-Extensions header situated at offs in buf and adds them to the passed PWSExt values.
ParseAllWSProtoValues tries to parse all the values in a Sec-WebSocket-Protocol header situated at offs in buf and adds them to the passed PWSProto values.
ParseChunk parses a chunk "delimiter".
ParseCLenVal parses a Content-Length header value, starting at offs in buf and filling pcl.
ParseFLine parses the request/response line (first line) of a HTTP message.
ParseHdrLine parses a header from a HTTP message.
ParseHeaders parses all the headers till end of header marker (double CRLF).
ParseMsg parses a HTTP 1.x message contained in buf[], starting at offset offs.
ParseTokenLst iterates through a comma or space separated token list, returning each token in turn.
ParseTokenParam will parse a string of the form param [= value] [;] .
ParseUIntVal parses the value/content of a header containing an uint (e.g.
SkipBody will find the type of the message body and skip over it or "continue" skipping.
SkipQuoted skips a quoted string, looking for the end quote.
TrEncResolve will try to resolve the extension name to a numeriv TrEncT flag.
UpgProtoGet will try to resolve the protocol name to a numeriv UpgProtoT flag.
WSExtResolve will try to resolve the extension name to a numeriv WSExtT flag.
WSProtoResolve will try to resolve the protocol name to a numeriv WSProtoT flag.
# Constants
always last.
Possible error value for header parsing functions.
Possible error value for header parsing functions.
Possible error value for header parsing functions.
empty header (e.g.
header end.
more input needed (premature end).
more contacts, call again.
no Content-Length header and Content-Length required.
Possible error value for header parsing functions.
Possible error value for header parsing functions.
no error, equiv.
Possible error value for header parsing functions.
Possible error value for header parsing functions.
Possible error value for header parsing functions.
Possible error value for header parsing functions.
Possible error value for header parsing functions.
Possible error value for header parsing functions.
HdrT header types constants.
HdrFlags constants for each header type.
HdrT header types constants.
HdrFlags constants for each header type.
HdrT header types constants.
HdrFlags constants for each header type.
HdrT header types constants.
HdrFlags constants for each header type.
HdrT header types constants.
HdrT header types constants.
HdrFlags constants for each header type.
generic, not recognized header.
HdrFlags constants for each header type.
HdrT header types constants.
HdrFlags constants for each header type.
HdrT header types constants.
HdrFlags constants for each header type.
http 1.1 _only_ (not allower on 2.0).
HdrFlags constants for each header type.
HdrT header types constants.
HdrFlags constants for each header type.
HdrT header types constants.
HdrFlags constants for each header type.
HdrT header types constants.
HdrFlags constants for each header type.
HdrT header types constants.
HdrFlags constants for each header type.
HdrT header types constants.
HdrFlags constants for each header type.
numeric max.
MaxCLenValueSize holds the maximum length of the Content-Length value interpreted as string (more then 9 can overflow and uint32).
method types.
method types.
method types.
method types.
method types.
must be last.
method types.
method types.
method types.
parsing body based on Transfer-Encoding chunked.
skipping over the chunk data.
parsing body based on Content-Length.
parsing body till connection is closed.
Parsing states.
Parsing states.
fully parsed.
Parsing states.
Parsing states.
Parsing states.
message with no body.
no Content-Length and Content-Length required.
no more message data (e.g EOF), stop at end of buf.
don't parse the body (return offset = body start).
method types.
method types.
alow ;param=val.
alow '/' inside the token.
comma separated tokens.
inputs end at end of buf.
parsing flags.
whitespace separated tokens.
Transfer-Encoding flag values, see https://www.rfc-editor.org/rfc/rfc7230#section-4 and http://www.iana.org/assignments/http-parameters/http-parameters.xhtml#transfer-coding.
Transfer-Encoding flag values, see https://www.rfc-editor.org/rfc/rfc7230#section-4 and http://www.iana.org/assignments/http-parameters/http-parameters.xhtml#transfer-coding.
Transfer-Encoding flag values, see https://www.rfc-editor.org/rfc/rfc7230#section-4 and http://www.iana.org/assignments/http-parameters/http-parameters.xhtml#transfer-coding.
Transfer-Encoding flag values, see https://www.rfc-editor.org/rfc/rfc7230#section-4 and http://www.iana.org/assignments/http-parameters/http-parameters.xhtml#transfer-coding.
Transfer-Encoding flag values, see https://www.rfc-editor.org/rfc/rfc7230#section-4 and http://www.iana.org/assignments/http-parameters/http-parameters.xhtml#transfer-coding.
Transfer-Encoding flag values, see https://www.rfc-editor.org/rfc/rfc7230#section-4 and http://www.iana.org/assignments/http-parameters/http-parameters.xhtml#transfer-coding.
unknown/other.
not an actual encoding, used in TE.
obsolete.
obsolete.
Upgrade protocol flags values, see https://www.iana.org/assignments/http-upgrade-tokens/http-upgrade-tokens.xhtml#http-upgrade-tokens-1.
Upgrade protocol flags values, see https://www.iana.org/assignments/http-upgrade-tokens/http-upgrade-tokens.xhtml#http-upgrade-tokens-1.
unknown/other.
Upgrade protocol flags values, see https://www.iana.org/assignments/http-upgrade-tokens/http-upgrade-tokens.xhtml#http-upgrade-tokens-1.
Sec-WebSocket-Extensions flag values, see https://www.iana.org/assignments/websocket/websocket.xhtml#extension-name.
unknown/other.
Sec-WebSocket-Extensions flag values, see https://www.iana.org/assignments/websocket/websocket.xhtml#extension-name.
Sec-WebSocket-Protocol flag values, see https://www.iana.org/assignments/websocket/websocket.xhtml#subprotocol-name.
Sec-WebSocket-Protocol flag values, see https://www.iana.org/assignments/websocket/websocket.xhtml#subprotocol-name.
unknown/other.
Sec-WebSocket-Protocol flag values, see https://www.iana.org/assignments/websocket/websocket.xhtml#subprotocol-name.
Sec-WebSocket-Protocol flag values, see https://www.iana.org/assignments/websocket/websocket.xhtml#subprotocol-name.
# Variables
Method2Name translates between a numeric HTTPMethod and the ASCII name.
# Structs
ChunkVal contains a parsed "chunk" delimiter.
Hdr contains a partial or fully parsed header.
HdrIState contains internal header parsing state.
HdrLst groups a list of parsed headers.
HdrLstIState contains internal HdrLst parsing state.
PField is the type for parsed fields (like host, to body a.s.o.).
PFLine contains the parsed first line of a HTTP message (request or reply).
PFLineIState contains internal parsing state associated to a PFLine.
PHdrVals holds all the header specific parsed values structures.
No description provided by the author
HTTPMsgIState holds the internal parsing state.
PToken contains a parsed token, complete with internal parsing state (that would allow continuing parsing in some cases).
internal state.
PTokParam contains a token parameter.
PTrEnc contains the parsed Transfer-Encoding header values for one or more different headers (all the transfer encodings in the message that fit in the parsed value array).
PUIntBody holds a partial or fully parsed unsigned int header value.
PUIntIState contains ParseUIntVal internal state info (private).
PUpgrade contains the parsed Upgrade header values for one or more different Upgrade headers (all the upgrade protocols in the message that fit in the parsed value array).
PWSExt contains the parsed Sec-WebSocket-Extensions header values for one or more different headers (all the websocket extensions in the message that fit in the parsed value array).
PWSProto contains the parsed Sec-WebSocket-Protocol header values for one or more different headers (all the websocket sub-protocols in the message that fit in the parsed value array).
TrEncVal contains a parsed "Transfer-Encoding" or "TE" value.
UpgProtoVal contains a parsed "Upgrade" protocol value.
WSExtVal contains a parsed "Sec-WebSocket-Extension" value.
WSProtoVal contains a parsed "Sec-WebSocket-Protocol" value.
# Interfaces
PHBodies defines an interface for getting pointers to parsed bodies structs.
# Type aliases
ErrorHdr is the type for the errors returned by various header parsing functions.
HdrFlags packs several header values into bit flags.
HdrT is used to hold the header type as a numeric constant.
HTTPMethod is the type used to hold the various SIP request methods.
No description provided by the author
OffsT is the type used for offset and length used internally in PField.
TrEncT is the type for the web socket extension converted to a flag value.
UpgProtoT is the type for the upgrade protocol converted to a numeric flag.
WSExtT is the type for the web socket extension converted to a flag value.
WSProtoT is the type for the web socket protocol converted to a flag value.