From 08aadf818178f22708060ccac7ff7c9bb8e079dd Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Wed, 22 Oct 2014 15:28:20 +0200 Subject: [PATCH] message parser --- http/Message/Parser.md | 45 +++++++++++++++++++++++++++++++++ http/Message/Parser/getState.md | 16 ++++++++++++ http/Message/Parser/parse.md | 20 +++++++++++++++ http/Message/Parser/stream.md | 21 +++++++++++++++ 4 files changed, 102 insertions(+) create mode 100644 http/Message/Parser.md create mode 100644 http/Message/Parser/getState.md create mode 100644 http/Message/Parser/parse.md create mode 100644 http/Message/Parser/stream.md 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 -- 2.30.2