From: Michael Wallner Date: Wed, 22 Oct 2014 13:28:20 +0000 (+0200) Subject: message parser X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=08aadf818178f22708060ccac7ff7c9bb8e079dd;p=mdref%2Fmdref-http message parser --- diff --git a/http/Message/Parser.md b/http/Message/Parser.md new file mode 100644 index 0000000..78398fd --- /dev/null +++ b/http/Message/Parser.md @@ -0,0 +1,45 @@ +# class http\Message\Parser + +The parser which is underlying http\Message. + +## Changelog: + +| Version | Change +|---------|-------- +| 2.2.0 | Added http\Message\Parser API + +## Constants: + +### Parser flags: + +* CLEANUP + Finish up parser at end of (incomplete) input. +* DUMB_BODIES + Soak up the rest of input if no entity length is deducible. +* EMPTY_REDIRECTS + Redirect messages do not contain any body despite of indication of such. +* GREEDY + Continue parsing while input is available. + +### Parser states: + +* STATE_FAILURE + Parse failure. +* STATE_START + Expecting HTTP info (request/response line) or headers. +* STATE_HEADER + Parsing headers. +* STATE_HEADER_DONE + Completed parsing headers. +* STATE_BODY + Parsing the body. +* STATE_BODY_DUMB + Soaking up all input as body. +* STATE_BODY_LENGTH + Reading body as indicated by `Content-Lenght` or `Content-Range`. +* STATE_BODY_CHUNKED + Parsing `chunked` encoded body. +* STATE_BODY_DONE + Finished parsing the body. +* STATE_DONE + Finished parsing the message. diff --git a/http/Message/Parser/getState.md b/http/Message/Parser/getState.md new file mode 100644 index 0000000..b0c7e1d --- /dev/null +++ b/http/Message/Parser/getState.md @@ -0,0 +1,16 @@ +# int http\Message\Parser::getState() + +Retrieve the current state of the parser. +See http\Message\Parser::STATE_* constants. + +## Params: + +None. + +## Returns: + +* int, http\Message\Parser::STATE_* constant. + +## Throws: + +* http\Exception\InvalidArgumentException diff --git a/http/Message/Parser/parse.md b/http/Message/Parser/parse.md new file mode 100644 index 0000000..cb9575d --- /dev/null +++ b/http/Message/Parser/parse.md @@ -0,0 +1,20 @@ +# int http\Message\Parser::parse(string $data, int $flags, http\Message &$message) + +Parse a string. + +## Params: + +* string $data + The (part of the) message to parse. +* int $flags + Any combination of [parser flags](http/Message/Parser#Parser.flags:). +* http\Message &$message + The current state of the message parsed. + +## Returns: + +* int, http\Message\Parser::STATE_* constant. + +## Throws: + +* http\Exception\InvalidArgumentException diff --git a/http/Message/Parser/stream.md b/http/Message/Parser/stream.md new file mode 100644 index 0000000..717c82a --- /dev/null +++ b/http/Message/Parser/stream.md @@ -0,0 +1,21 @@ +# int http\Message\Parser::stream(resource $stream, int $flags, http\Message &$message) + +Parse a stream. + +## Params: + +* stream $resource + The message stream to parse from. +* int $flags + Any combination of [parser flags](http/Message/Parser#Parser.flags:). +* http\Message &$message + The current state of the message parsed. + +## Returns: + +* int, http\Message\Parser::STATE_* constant. + +## Throws: + +* http\Exception\InvalidArgumentException +* http\Exception\UnexpectedValueException