From c2e4d7edf424ea7684c31fc15310ab563a27725f Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Wed, 12 Nov 2014 14:11:10 +0100 Subject: [PATCH] 2.2.0 --- http/Env/Request.md | 8 +++++ http/Env/Request/getCookie.md | 25 +++++++++++++++ http/Env/Response.md | 8 +++++ http/Env/Response/setCookie.md | 56 ++++++++++++++++++++++++++++++++++ 4 files changed, 97 insertions(+) create mode 100644 http/Env/Request/getCookie.md create mode 100644 http/Env/Response/setCookie.md diff --git a/http/Env/Request.md b/http/Env/Request.md index 75161a6..6aef6c7 100644 --- a/http/Env/Request.md +++ b/http/Env/Request.md @@ -4,6 +4,12 @@ The http\Env\Request class' instances represent the server's current HTTP reques See http\Message for inherited members. +## Changelog: + +Version | Changes +--------|-------- +2.2.0 | Added http\Env\Request::getCookie() and http\Env\Request::$cookie. + ## Constants: None. @@ -16,3 +22,5 @@ None. The request's form parameters. ($_POST) * protected array $files = NULL The request's form uploads. ($_FILES) +* protected array $cookie = NULL + The request's cookies. ($_COOKIE) diff --git a/http/Env/Request/getCookie.md b/http/Env/Request/getCookie.md new file mode 100644 index 0000000..d74f669 --- /dev/null +++ b/http/Env/Request/getCookie.md @@ -0,0 +1,25 @@ +# mixed http\Env\Request::getCookie([string $name = NULL[, mixed $type = NULL[, mixed $defval = NULL[, bool $delete = false]]]]) + +Retrieve an URL query value ($_GET). + +See http\QueryString::get() and http\QueryString::TYPE_* constants. + +## Params: + +* Optional string $name = NULL + The key to retrieve the value for. +* Optional mixed $type = NULL + The type to cast the value to. See http\QueryString::TYPE_* constants. +* Optional mixed $defval = NULL + The default value to return if the key $name does not exist. +* Optional bool $delete = false + Whether to delete the entry from the querystring after retrieval. + + +## Returns: + +* http\QueryString, if called without arguments. +* string, the whole querystring if $name is of zero length. +* mixed, $defval if the key $name does not exist. +* mixed, the querystring value cast to $type if $type was specified and the key $name exists. +* string, the querystring value if the key $name exists and $type is not specified or equals http\QueryString::TYPE_STRING. diff --git a/http/Env/Response.md b/http/Env/Response.md index 8aaee1f..2b36921 100644 --- a/http/Env/Response.md +++ b/http/Env/Response.md @@ -4,6 +4,12 @@ The http\Env\Response class' instances represent the server's current HTTP respo See http\Message for inherited members. +## Changelog: + +Version | Changes +--------|-------- +2.2.0 | Added http\Env\Response::setCookie() and http\Env\Response::$cookies. + ## Constants: * CONTENT_ENCODING_NONE @@ -37,3 +43,5 @@ See http\Message for inherited members. Any throttling delay. * protected int $throttleChunk = NULL The chunk to send every $throttleDelay seconds. +* protected array $cookies = NULL + The response's cookies. diff --git a/http/Env/Response/setCookie.md b/http/Env/Response/setCookie.md new file mode 100644 index 0000000..c61c0bc --- /dev/null +++ b/http/Env/Response/setCookie.md @@ -0,0 +1,56 @@ +# http\Env\Response http\Env\Response::setCookie(mixed $cookie) + +Add cookies to the response to send. + +## Params: + +* mixed $cookie + The cookie to send. + +## Returns: + +* http\Env\Response, self. + +## Throws: + +* http\Exception\InvalidArgumentException +* http\Exception\UnexpectedValueException + +## Example: + + setCookie("visit=true; path=/"); + $r->send(STDOUT); + + ?> + +Yields: + + HTTP/1.1 200 OK + Set-Cookie: visit=true; path=/; + ETag: "" + +### Another example: + + addCookie("foo", "bar"); + $c->setMaxAge(360); + $c->setDomain(".example.org"); + $c->setPath("/"); + $c->setFlags(http\Cookie::SECURE | http\Cookie::HTTPONLY); + + $r = new http\Env\Response; + $r->setCookie($c); + $r->send(STDOUT); + + ?> + +Yields: + + HTTP/1.1 200 OK + Set-Cookie: foo=bar; domain=.example.org; path=/; max-age=360; secure; httpOnly; + ETag: "" -- 2.30.2