From 5a58cf58b42ab2fc6b09d1499d5e9ea4d65f579c Mon Sep 17 00:00:00 2001 From: Philipp Kewisch Date: Wed, 29 Oct 2014 16:35:27 +0100 Subject: [PATCH 01/19] Fix typo in client test --- tests/HTTP/ClientTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/HTTP/ClientTest.php b/tests/HTTP/ClientTest.php index 1ffcb51..02c0cec 100644 --- a/tests/HTTP/ClientTest.php +++ b/tests/HTTP/ClientTest.php @@ -389,7 +389,7 @@ protected function curlStuff($curlHandle) { // If nothing modified $return, we're using the default behavior. if (is_null($return)) { - return parent::curlStufF($curlHandle); + return parent::curlStuff($curlHandle); } else { return $return; } From 29d41bdc8bd4ec36833f0c16e003f7964e751634 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Tue, 4 Nov 2014 15:27:39 +0100 Subject: [PATCH 02/19] Fix typos. --- README.md | 52 ++++++++++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 0a61137..a749b6b 100644 --- a/README.md +++ b/README.md @@ -12,15 +12,15 @@ effectively a wrapper around the following PHP constructs: For Input: -* `$_GET` -* `$_POST` -* `$_SERVER` +* `$_GET`, +* `$_POST`, +* `$_SERVER`, * `php://input` or `$HTTP_RAW_POST_DATA`. For output: -* `php://output` or `echo`. -* `header()` +* `php://output` or `echo`, +* `header()`. What this library provides, is a `Request` object, and a `Response` object. @@ -39,7 +39,6 @@ Installation Make sure you have [composer][1] installed. In your project directory, create, or edit a `composer.json` file, and make sure it contains something like this: - ```json { "require" : { @@ -53,18 +52,18 @@ After that, just hit `composer install` and you should be rolling. Quick history ------------- -This library came to existence in 2009, as a part of the [SabreDAV][2] +This library came to existence in 2009, as a part of the [`sabre/dav`][2] project, which uses it heavily. It got split off into a separate library to make it easier to manage -releases and hopefully giving it use outside of the scope of just SabreDAV. +releases and hopefully giving it use outside of the scope of just `sabre/dav`. Although completely independently developed, this library has a LOT of -overlap with [symfony's HttpFoundation][3]. +overlap with [Symfony's `HttpFoundation`][3]. Said library does a lot more stuff and is significantly more popular, so if you are looking for something to fulfill this particular requirement, -I'd recommend also considering [HttpFoundation][3]. +I'd recommend also considering [`HttpFoundation`][3]. Getting started @@ -96,7 +95,6 @@ function handleRequest(HTTP\RequestInterface $request) { A response object you can just create as such: - ```php use Sabre\HTTP; @@ -120,29 +118,28 @@ HTTP\Sapi::sendResponse($response); This line should generally also appear once in your application (at the very end). - Decorators ---------- -It may be useful to extend the Request and Response objects in your +It may be useful to extend the `Request` and `Response` objects in your application, if you for example would like them to carry a bit more information about the current request. -For instance, you may want to add an `isLoggedIn()` method to the Request +For instance, you may want to add an `isLoggedIn` method to the Request object. Simply extending Request and Response may pose some problems: -1. You may want to extend the objects with new behavior differently, in - different subsystems of your application. +1. You may want to extend the objects with new behaviors differently, in + different subsystems of your application, 2. The `Sapi::getRequest` factory always returns a instance of - `Request` so you would have to override the factory method as well. + `Request` so you would have to override the factory method as well, 3. By controlling the instantation and depend on specific `Request` and `Response` instances in your library or application, you make it harder to work with other applications which also use `sabre/http`. In short: it would be bad design. Instead, it's recommended to use the -[decorator pattern][6] to add new behavior where you need it. sabre/http +[decorator pattern][6] to add new behavior where you need it. `sabre/http` provides helper classes to quickly do this. Example: @@ -185,8 +182,8 @@ This package also contains a simple wrapper around [cURL][4], which will allow you to write simple clients, using the `Request` and `Response` objects you're already familiar with. -It's by no means a replacement for something like [guzzle][7], but it provides -a simple and lightweight api for making the occasional API call. +It's by no means a replacement for something like [Guzzle][7], but it provides +a simple and lightweight API for making the occasional API call. ### Usage @@ -202,7 +199,7 @@ $response = $client->send($request); echo $response->getBodyAsString(); ``` -The client emits 3 event using [sabre/event][5]. `beforeRequest`, +The client emits 3 event using [`sabre/event`][5]. `beforeRequest`, `afterRequest` and `error`. ```php @@ -245,11 +242,11 @@ $client->on('error:401', function($request, $response, &$retry, $retryCount) { ### Asynchronous requests -The Client also supports doing asynchronous requests. This is especially handy +The `Client` also supports doing asynchronous requests. This is especially handy if you need to perform a number of requests, that are allowed to be executed in parallel. -The underlying system for this is simply [curl's multi request handler][8], +The underlying system for this is simply [cURL's multi request handler][8], but this provides a much nicer API to handle this. Sample usage: @@ -279,7 +276,7 @@ $client->wait(); ``` -Check out examples/asyncclient.php for more information. +Check out `examples/asyncclient.php` for more information. Writing a reverse proxy ----------------------- @@ -323,7 +320,6 @@ $response = $client->send($subRequest); Sapi::sendResponse($response); ``` - The Request and Response API's ------------------------------ @@ -741,10 +737,10 @@ Made at fruux This library is being developed by [fruux](https://fruux.com/). Drop us a line for commercial services or enterprise support. [1]: http://getcomposer.org/ -[2]: http://code.google.com/p/sabredav +[2]: http://sabre.io/ [3]: https://github.com/symfony/HttpFoundation -[4]: http://uk3.php.net/curl +[4]: http://php.net/curl [5]: https://github.com/fruux/sabre-event [6]: http://en.wikipedia.org/wiki/Decorator_pattern [7]: http://guzzlephp.org/ -[8]: http://www.php.net/manual/en/function.curl-multi-init.php +[8]: http://php.net/curl_multi_init From e9ee07f53f52cf18c9f66d748b7608825117f17f Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Tue, 4 Nov 2014 15:41:37 +0100 Subject: [PATCH 03/19] mv EMPTY .empty Just hide the file, will get less questions like this ;-). --- bin/{EMPTY => .empty} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename bin/{EMPTY => .empty} (100%) diff --git a/bin/EMPTY b/bin/.empty similarity index 100% rename from bin/EMPTY rename to bin/.empty From 4a2c4d2df022a6b93ac5a515b7ecc73255d0e78c Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Tue, 4 Nov 2014 15:44:46 +0100 Subject: [PATCH 04/19] Remove a useless `else`. --- lib/Request.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/Request.php b/lib/Request.php index f1c1651..e626840 100644 --- a/lib/Request.php +++ b/lib/Request.php @@ -205,11 +205,9 @@ function getPath() { return ''; - } else { - - throw new \LogicException('Requested uri (' . $this->getUrl() . ') is out of base uri (' . $this->getBaseUrl() . ')'); - } + + throw new \LogicException('Requested uri (' . $this->getUrl() . ') is out of base uri (' . $this->getBaseUrl() . ')'); } /** From e59df0a762fd4a55fa2af1229189ed67c7c3b8bb Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Tue, 4 Nov 2014 15:56:19 +0100 Subject: [PATCH 05/19] Rename a variable and fix CS. --- lib/Request.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Request.php b/lib/Request.php index e626840..c0f2df6 100644 --- a/lib/Request.php +++ b/lib/Request.php @@ -291,19 +291,21 @@ function setRawServerData(array $data) { */ function __toString() { - $str = $this->getMethod() . ' ' . $this->getUrl() . ' HTTP/' . $this->getHTTPVersion() . "\r\n"; + $out = $this->getMethod() . ' ' . $this->getUrl() . ' HTTP/' . $this->getHTTPVersion() . "\r\n"; + foreach($this->getHeaders() as $key=>$value) { foreach($value as $v) { if ($key==='Authorization') { list($v) = explode(' ', $v,2); $v .= ' REDACTED'; } - $str.= $key . ": " . $v . "\r\n"; + $out .= $key . ": " . $v . "\r\n"; } } - $str.="\r\n"; - $str.=$this->getBodyAsString(); - return $str; + $out .= "\r\n"; + $out .= $this->getBodyAsString(); + + return $out; } From c6a7266f062f39850f4ae17f26fb6aa46570fc32 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Tue, 4 Nov 2014 16:21:46 +0100 Subject: [PATCH 06/19] Add status 103 and 308 and fix status messages. --- lib/Response.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Response.php b/lib/Response.php index 6b5ba3d..30a05a9 100644 --- a/lib/Response.php +++ b/lib/Response.php @@ -38,7 +38,8 @@ class Response extends Message implements ResponseInterface { 305 => 'Use Proxy', 306 => 'Reserved', 307 => 'Temporary Redirect', - 400 => 'Bad request', + 308 => 'Permanent Redirect', + 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', @@ -60,8 +61,8 @@ class Response extends Message implements ResponseInterface { 422 => 'Unprocessable Entity', // RFC 4918 423 => 'Locked', // RFC 4918 424 => 'Failed Dependency', // RFC 4918 - 426 => 'Upgrade required', - 428 => 'Precondition required', // RFC 6585 + 426 => 'Upgrade Required', + 428 => 'Precondition Required', // RFC 6585 429 => 'Too Many Requests', // RFC 6585 431 => 'Request Header Fields Too Large', // RFC 6585 451 => 'Unavailable For Legal Reasons', // draft-tbray-http-legally-restricted-status From 8ebcd7940f042d85905ec0e2bdd6d539bc5a1e27 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Wed, 5 Nov 2014 10:31:01 +0100 Subject: [PATCH 07/19] =?UTF-8?q?>=20399=20->=20>=3D=20400=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … to be consistent with other declarations. --- lib/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Client.php b/lib/Client.php index 1ff5b69..e820eba 100644 --- a/lib/Client.php +++ b/lib/Client.php @@ -150,7 +150,7 @@ function send(RequestInterface $request) { $this->emit('afterRequest', [$request, $response]); - if ($this->throwExceptions && $code > 399) { + if ($this->throwExceptions && $code >= 400) { throw new ClientHttpException($response); } From 270d87e61ce39e1e34ce78194bfa073387963df9 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Wed, 5 Nov 2014 10:30:18 +0100 Subject: [PATCH 08/19] Fix typos in comments. --- lib/Client.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Client.php b/lib/Client.php index 1ff5b69..614131f 100644 --- a/lib/Client.php +++ b/lib/Client.php @@ -110,7 +110,7 @@ function send(RequestInterface $request) { $oldLocation = $request->getUrl(); - // Creating an new instance of the request object. + // Creating a new instance of the request object. $request = clone $request; // Setting the new location @@ -286,10 +286,10 @@ function wait() { /** * If this is set to true, the Client will automatically throw exceptions - * upon http errors. + * upon HTTP errors. * - * This means that if a response came back with a status code of 400 or - * higher, we will throw a ClientHttpException. + * This means that if a response came back with a status code greater than + * or equal to 400, we will throw a ClientHttpException. * * This only works for the send() method. Throwing exceptions for * sendAsync() is not supported. From a7a5c745b8c6a358c5a5a1fb835cf99274d7aea8 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Wed, 5 Nov 2014 13:35:45 +0100 Subject: [PATCH 09/19] Remove unnecessary else and elseif with return. --- lib/Message.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/Message.php b/lib/Message.php index bdc4bc5..6afd186 100644 --- a/lib/Message.php +++ b/lib/Message.php @@ -52,9 +52,8 @@ function getBodyAsStream() { fwrite($stream, $body); rewind($stream); return $stream; - } else { - return $body; } + return $body; } @@ -71,11 +70,11 @@ function getBodyAsString() { $body = $this->getBody(); if (is_string($body)) { return $body; - } elseif (is_null($body)) { + } + if (is_null($body)) { return ''; - } else { - return stream_get_contents($body); } + return stream_get_contents($body); } @@ -195,9 +194,7 @@ function getHeaderAsArray($name) { */ function setHeader($name, $value) { - $this->headers[ - strtolower($name) - ] = [$name, (array)$value]; + $this->headers[strtolower($name)] = [$name, (array)$value]; } @@ -279,10 +276,9 @@ function removeHeader($name) { $name = strtolower($name); if (!isset($this->headers[$name])) { return false; - } else { - unset($this->headers[$name]); - return true; } + unset($this->headers[$name]); + return true; } From 20f1d3480c96885fc1024c2fb878ec8b9bff6094 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Wed, 5 Nov 2014 13:42:38 +0100 Subject: [PATCH 10/19] s/http/HTTP/ in API documentation. --- lib/Message.php | 6 +++--- lib/MessageDecoratorTrait.php | 6 +++--- lib/MessageInterface.php | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/Message.php b/lib/Message.php index bdc4bc5..d215774 100644 --- a/lib/Message.php +++ b/lib/Message.php @@ -121,7 +121,7 @@ function getHeaders() { } /** - * Will return true or false, depending on if a http header exists. + * Will return true or false, depending on if a HTTP header exists. * * @param string $name * @return bool @@ -138,7 +138,7 @@ function hasHeader($name) { * The name must be treated as case-insensitive. * If the header does not exist, this method must return null. * - * If a header appeared more than once in a http request, this method will + * If a header appeared more than once in a HTTP request, this method will * concatenate all the values with a comma. * * Note that this not make sense for all headers. Some, such as @@ -162,7 +162,7 @@ function getHeader($name) { /** * Returns a HTTP header as an array. * - * For every time the http header appeared in the request or response, an + * For every time the HTTP header appeared in the request or response, an * item will appear in the array. * * If the header did not exists, this method will return an empty array. diff --git a/lib/MessageDecoratorTrait.php b/lib/MessageDecoratorTrait.php index 474ac94..b744b3f 100644 --- a/lib/MessageDecoratorTrait.php +++ b/lib/MessageDecoratorTrait.php @@ -91,7 +91,7 @@ function getHeaders() { } /** - * Will return true or false, depending on if a http header exists. + * Will return true or false, depending on if a HTTP header exists. * * @param string $name * @return bool @@ -108,7 +108,7 @@ function hasHeader($name) { * The name must be treated as case-insensitive. * If the header does not exist, this method must return null. * - * If a header appeared more than once in a http request, this method will + * If a header appeared more than once in a HTTP request, this method will * concatenate all the values with a comma. * * Note that this not make sense for all headers. Some, such as @@ -127,7 +127,7 @@ function getHeader($name) { /** * Returns a HTTP header as an array. * - * For every time the http header appeared in the request or response, an + * For every time the HTTP header appeared in the request or response, an * item will appear in the array. * * If the header did not exists, this method will return an empty array. diff --git a/lib/MessageInterface.php b/lib/MessageInterface.php index 3e44cca..e0e75f5 100644 --- a/lib/MessageInterface.php +++ b/lib/MessageInterface.php @@ -59,7 +59,7 @@ function setBody($body); function getHeaders(); /** - * Will return true or false, depending on if a http header exists. + * Will return true or false, depending on if a HTTP header exists. * * @param string $name * @return bool @@ -72,7 +72,7 @@ function hasHeader($name); * The name must be treated as case-insensitive. * If the header does not exist, this method must return null. * - * If a header appeared more than once in a http request, this method will + * If a header appeared more than once in a HTTP request, this method will * concatenate all the values with a comma. * * Note that this not make sense for all headers. Some, such as @@ -87,7 +87,7 @@ function getHeader($name); /** * Returns a HTTP header as an array. * - * For every time the http header appeared in the request or response, an + * For every time the HTTP header appeared in the request or response, an * item will appear in the array. * * If the header did not exists, this method will return an empty array. From 7b3e45ff89c9053863559aecfa9eaef0c5c848b9 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Wed, 5 Nov 2014 14:27:43 +0100 Subject: [PATCH 11/19] Update @license link. --- lib/Auth/AWS.php | 2 +- lib/Auth/AbstractAuth.php | 2 +- lib/Auth/Basic.php | 2 +- lib/Auth/Digest.php | 2 +- lib/Client.php | 2 +- lib/ClientException.php | 2 +- lib/ClientHttpException.php | 2 +- lib/HttpException.php | 2 +- lib/Message.php | 2 +- lib/MessageDecoratorTrait.php | 2 +- lib/MessageInterface.php | 2 +- lib/Request.php | 2 +- lib/RequestDecorator.php | 2 +- lib/RequestInterface.php | 2 +- lib/Response.php | 2 +- lib/ResponseDecorator.php | 2 +- lib/ResponseInterface.php | 2 +- lib/Sapi.php | 2 +- lib/URLUtil.php | 2 +- lib/Util.php | 2 +- lib/Version.php | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) diff --git a/lib/Auth/AWS.php b/lib/Auth/AWS.php index d4b8489..bfdc513 100644 --- a/lib/Auth/AWS.php +++ b/lib/Auth/AWS.php @@ -11,7 +11,7 @@ * * @copyright Copyright (C) 2009-2014 fruux GmbH (https://fruux.com/). * @author Evert Pot (http://evertpot.com/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ class AWS extends AbstractAuth { diff --git a/lib/Auth/AbstractAuth.php b/lib/Auth/AbstractAuth.php index fb9d1e1..a0169ac 100644 --- a/lib/Auth/AbstractAuth.php +++ b/lib/Auth/AbstractAuth.php @@ -13,7 +13,7 @@ * * @copyright Copyright (C) 2009-2014 fruux GmbH (https://fruux.com/). * @author Evert Pot (http://evertpot.com/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ abstract class AbstractAuth { diff --git a/lib/Auth/Basic.php b/lib/Auth/Basic.php index 72dbee5..d2f9bc8 100644 --- a/lib/Auth/Basic.php +++ b/lib/Auth/Basic.php @@ -13,7 +13,7 @@ * * @copyright Copyright (C) 2009-2014 fruux GmbH (https://fruux.com/). * @author Evert Pot (http://evertpot.com/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ class Basic extends AbstractAuth { diff --git a/lib/Auth/Digest.php b/lib/Auth/Digest.php index 44f7e7d..cf0fc6c 100644 --- a/lib/Auth/Digest.php +++ b/lib/Auth/Digest.php @@ -26,7 +26,7 @@ * * @copyright Copyright (C) 2009-2014 fruux GmbH (https://fruux.com/). * @author Evert Pot (http://evertpot.com/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ class Digest extends AbstractAuth { diff --git a/lib/Client.php b/lib/Client.php index 1ff5b69..a283012 100644 --- a/lib/Client.php +++ b/lib/Client.php @@ -38,7 +38,7 @@ * * @copyright Copyright (C) 2009-2014 fruux GmbH. All rights reserved. * @author Evert Pot (http://evertpot.com/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ class Client extends EventEmitter { diff --git a/lib/ClientException.php b/lib/ClientException.php index fd203ad..622047f 100644 --- a/lib/ClientException.php +++ b/lib/ClientException.php @@ -8,7 +8,7 @@ * * @copyright Copyright (C) 2009-2014 fruux GmbH. All rights reserved. * @author Evert Pot (http://evertpot.com/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ class ClientException extends \Exception { diff --git a/lib/ClientHttpException.php b/lib/ClientHttpException.php index e771004..8623390 100644 --- a/lib/ClientHttpException.php +++ b/lib/ClientHttpException.php @@ -10,7 +10,7 @@ * * @copyright Copyright (C) 2009-2014 fruux GmbH. All rights reserved. * @author Evert Pot (http://evertpot.com/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ class ClientHttpException extends \Exception implements HttpException { diff --git a/lib/HttpException.php b/lib/HttpException.php index 6afdb7f..eca2c3c 100644 --- a/lib/HttpException.php +++ b/lib/HttpException.php @@ -13,7 +13,7 @@ * * @copyright Copyright (C) 2009-2014 fruux GmbH. All rights reserved. * @author Evert Pot (http://evertpot.com/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ interface HttpException { diff --git a/lib/Message.php b/lib/Message.php index bdc4bc5..8ae7f3c 100644 --- a/lib/Message.php +++ b/lib/Message.php @@ -9,7 +9,7 @@ * * @copyright Copyright (C) 2009-2014 fruux GmbH (https://fruux.com/). * @author Evert Pot (http://evertpot.com/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ abstract class Message implements MessageInterface { diff --git a/lib/MessageDecoratorTrait.php b/lib/MessageDecoratorTrait.php index 474ac94..95cbe09 100644 --- a/lib/MessageDecoratorTrait.php +++ b/lib/MessageDecoratorTrait.php @@ -11,7 +11,7 @@ * * @copyright Copyright (C) 2009-2014 fruux GmbH (https://fruux.com/). * @author Evert Pot (http://evertpot.com/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ trait MessageDecoratorTrait { diff --git a/lib/MessageInterface.php b/lib/MessageInterface.php index 3e44cca..90409b1 100644 --- a/lib/MessageInterface.php +++ b/lib/MessageInterface.php @@ -8,7 +8,7 @@ * * @copyright Copyright (C) 2009-2014 fruux GmbH (https://fruux.com/). * @author Evert Pot (http://evertpot.com/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ interface MessageInterface { diff --git a/lib/Request.php b/lib/Request.php index f1c1651..9410a23 100644 --- a/lib/Request.php +++ b/lib/Request.php @@ -12,7 +12,7 @@ * * @copyright Copyright (C) 2009-2014 fruux GmbH (https://fruux.com/). * @author Evert Pot (http://evertpot.com/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ class Request extends Message implements RequestInterface { diff --git a/lib/RequestDecorator.php b/lib/RequestDecorator.php index f5a8678..12c0d11 100644 --- a/lib/RequestDecorator.php +++ b/lib/RequestDecorator.php @@ -10,7 +10,7 @@ * * @copyright Copyright (C) 2009-2014 fruux GmbH. All rights reserved. * @author Evert Pot (http://evertpot.com/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ class RequestDecorator implements RequestInterface { diff --git a/lib/RequestInterface.php b/lib/RequestInterface.php index f73a09f..46459ef 100644 --- a/lib/RequestInterface.php +++ b/lib/RequestInterface.php @@ -7,7 +7,7 @@ * * @copyright Copyright (C) 2009-2014 fruux GmbH (https://fruux.com/). * @author Evert Pot (http://evertpot.com/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ interface RequestInterface extends MessageInterface { diff --git a/lib/Response.php b/lib/Response.php index 30a05a9..d3adbbc 100644 --- a/lib/Response.php +++ b/lib/Response.php @@ -7,7 +7,7 @@ * * @copyright Copyright (C) 2009-2014 fruux GmbH (https://fruux.com/). * @author Evert Pot (http://evertpot.com/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ class Response extends Message implements ResponseInterface { diff --git a/lib/ResponseDecorator.php b/lib/ResponseDecorator.php index da28016..ac992ff 100644 --- a/lib/ResponseDecorator.php +++ b/lib/ResponseDecorator.php @@ -10,7 +10,7 @@ * * @copyright Copyright (C) 2009-2014 fruux GmbH. All rights reserved. * @author Evert Pot (http://evertpot.com/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ class ResponseDecorator implements ResponseInterface { diff --git a/lib/ResponseInterface.php b/lib/ResponseInterface.php index 0bf1101..1f39640 100644 --- a/lib/ResponseInterface.php +++ b/lib/ResponseInterface.php @@ -7,7 +7,7 @@ * * @copyright Copyright (C) 2009-2014 fruux GmbH (https://fruux.com/). * @author Evert Pot (http://evertpot.com/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ interface ResponseInterface extends MessageInterface { diff --git a/lib/Sapi.php b/lib/Sapi.php index 50094e5..90968a9 100644 --- a/lib/Sapi.php +++ b/lib/Sapi.php @@ -26,7 +26,7 @@ * * @copyright Copyright (C) 2007-2014 fruux GmbH. All rights reserved. * @author Evert Pot (http://evertpot.com/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ class Sapi { diff --git a/lib/URLUtil.php b/lib/URLUtil.php index e6ae402..ca5df74 100644 --- a/lib/URLUtil.php +++ b/lib/URLUtil.php @@ -16,7 +16,7 @@ * * @copyright Copyright (C) 2009-2014 fruux GmbH (https://fruux.com/). * @author Evert Pot (http://evertpot.com/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ class URLUtil { diff --git a/lib/Util.php b/lib/Util.php index bc70d08..93c50d3 100644 --- a/lib/Util.php +++ b/lib/Util.php @@ -8,7 +8,7 @@ * @copyright Copyright (C) 2009-2014 fruux GmbH (https://fruux.com/). * @author Evert Pot (http://evertpot.com/) * @author Paul Voegler - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ class Util { diff --git a/lib/Version.php b/lib/Version.php index 215a731..e658269 100644 --- a/lib/Version.php +++ b/lib/Version.php @@ -7,7 +7,7 @@ * * @copyright Copyright (C) 2009-2014 fruux GmbH (https://fruux.com/). * @author Evert Pot (http://evertpot.com/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ class Version { From 07cdf6267d4cb76486e43731fcddfdfd8f290c99 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Thu, 6 Nov 2014 15:02:52 +0100 Subject: [PATCH 12/19] Strict hours and days format. Avoid 29h, 00d or 36d for example. --- lib/Util.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Util.php b/lib/Util.php index 93c50d3..64b1113 100644 --- a/lib/Util.php +++ b/lib/Util.php @@ -27,11 +27,11 @@ static function parseHTTPDate($dateHeader) { $month = '(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)'; $weekday = '(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)'; $wkday = '(Mon|Tue|Wed|Thu|Fri|Sat|Sun)'; - $time = '[0-2]\d(\:[0-5]\d){2}'; - $date3 = $month . ' ([1-3]\d| \d)'; - $date2 = '[0-3]\d\-' . $month . '\-\d\d'; + $time = '([0-1]\d|2[0-3])(\:[0-5]\d){2}'; + $date3 = $month . ' ([12]\d|3[01]| [1-9])'; + $date2 = '(0[1-9]|[12]\d|3[01])\-' . $month . '\-\d{2}'; //4-digit year cannot begin with 0 - unix timestamp begins in 1970 - $date1 = '[0-3]\d ' . $month . ' [1-9]\d{3}'; + $date1 = '(0[1-9]|[12]\d|3[01]) ' . $month . ' [1-9]\d{3}'; //ANSI C's asctime() format //4-digit year cannot begin with 0 - unix timestamp begins in 1970 From e893b01704cd45c97ed96feb5a95322366b9a99b Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Thu, 6 Nov 2014 15:18:10 +0100 Subject: [PATCH 13/19] Add tests for invalid days and hours. --- tests/HTTP/UtilTest.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/HTTP/UtilTest.php b/tests/HTTP/UtilTest.php index 4a537b3..447c899 100644 --- a/tests/HTTP/UtilTest.php +++ b/tests/HTTP/UtilTest.php @@ -33,6 +33,16 @@ function testParseHTTPDateFail() { 'Wednesday, 13-Oct-10 10:26:00 UTC', // No space before the 6 'Wed Oct 6 10:26:00 2010', + // Invalid day + 'Wed Oct 0 10:26:00 2010', + 'Wed Oct 32 10:26:00 2010', + 'Wed, 0 Oct 2010 10:26:00 GMT', + 'Wed, 32 Oct 2010 10:26:00 GMT', + 'Wednesday, 32-Oct-10 10:26:00 GMT', + // Invalid hour + 'Wed, 13 Oct 2010 24:26:00 GMT', + 'Wednesday, 13-Oct-10 24:26:00 GMT', + 'Wed Oct 13 24:26:00 2010', ); foreach($times as $time) { From 466f7517bdc1f9ce473f08d06da6fb5d14c2a6d0 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Thu, 6 Nov 2014 15:33:38 +0100 Subject: [PATCH 14/19] Simplify the `splitPath` regular expression. --- lib/URLUtil.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/URLUtil.php b/lib/URLUtil.php index ca5df74..6d0feea 100644 --- a/lib/URLUtil.php +++ b/lib/URLUtil.php @@ -110,7 +110,7 @@ static function decodePathSegment($path) { static function splitPath($path) { $matches = array(); - if(preg_match('/^(?:(?:(.*)(?:\/+))?([^\/]+))(?:\/?)$/u',$path,$matches)) { + if(preg_match('/^(?:(.*)\/+)?([^\/]+)\/?$/u',$path,$matches)) { return array($matches[1],$matches[2]); } else { return array(null,null); From c1e6056a806f25b769a6514110081ca502923abf Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Thu, 6 Nov 2014 15:45:09 +0100 Subject: [PATCH 15/19] Update @evert informations ;-). --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 8071fac..d9d65f6 100644 --- a/composer.json +++ b/composer.json @@ -19,8 +19,8 @@ "authors" : [ { "name" : "Evert Pot", - "email" : "evert@rooftopsolutions.nl", - "homepage" : "http://www.rooftopsolutions.nl/", + "email" : "me@evertpot.com", + "homepage" : "http://evertpot.com/", "role" : "Developer" } ], From 3b38b981d26d890860ea205c17d07c21c9ea1efe Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Thu, 6 Nov 2014 15:47:17 +0100 Subject: [PATCH 16/19] Update @license link. --- examples/asyncclient.php | 2 +- examples/basicauth.php | 2 +- examples/client.php | 2 +- examples/stringify.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/asyncclient.php b/examples/asyncclient.php index 5c18871..cc6a3c7 100644 --- a/examples/asyncclient.php +++ b/examples/asyncclient.php @@ -8,7 +8,7 @@ * * @copyright Copyright (C) 2009-2014 fruux GmbH. All rights reserved. * @author Evert Pot (http://evertpot.com/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ use diff --git a/examples/basicauth.php b/examples/basicauth.php index 4aff032..ff49fc9 100644 --- a/examples/basicauth.php +++ b/examples/basicauth.php @@ -5,7 +5,7 @@ * * * @copyright Copyright (C) 2009-2014 fruux GmbH. All rights reserved. * @author Evert Pot (http://evertpot.com/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ $userList = [ diff --git a/examples/client.php b/examples/client.php index 6237e46..e1c0a3f 100644 --- a/examples/client.php +++ b/examples/client.php @@ -6,7 +6,7 @@ * * @copyright Copyright (C) 2009-2014 fruux GmbH. All rights reserved. * @author Evert Pot (http://evertpot.com/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ use diff --git a/examples/stringify.php b/examples/stringify.php index 10d4fe3..77cec65 100644 --- a/examples/stringify.php +++ b/examples/stringify.php @@ -8,7 +8,7 @@ * * @copyright Copyright (C) 2009-2014 fruux GmbH. All rights reserved. * @author Evert Pot (http://evertpot.com/) - * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License + * @license http://sabre.io/license/ Modified BSD License */ use From ab1255ad22c852048f32b35f382a0891000af358 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Thu, 6 Nov 2014 16:02:07 +0100 Subject: [PATCH 17/19] Use `hash_hmac` if available. In addition to a little CS fix (in order to be consistent). --- lib/Auth/AWS.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Auth/AWS.php b/lib/Auth/AWS.php index bfdc513..8f65dbc 100644 --- a/lib/Auth/AWS.php +++ b/lib/Auth/AWS.php @@ -215,9 +215,14 @@ protected function getAmzHeaders() { */ private function hmacsha1($key, $message) { + if (function_exists('hash_hmac')) { + return hash_hmac('sha1', $message, $key, true); + } + $blocksize=64; - if (strlen($key)>$blocksize) + if (strlen($key)>$blocksize) { $key=pack('H*', sha1($key)); + } $key=str_pad($key,$blocksize,chr(0x00)); $ipad=str_repeat(chr(0x36),$blocksize); $opad=str_repeat(chr(0x5c),$blocksize); From ad4f55ca7953c17339e3a4c2221c237a9bbc61bd Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 10 Nov 2014 08:26:38 +0100 Subject: [PATCH 18/19] 306 is now unused. Regarding http://tools.ietf.org/html/rfc7231#section-6.4.6: > The 306 status code was defined in a previous version of this > specification, is no longer used, and the code is reserved. --- lib/Response.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Response.php b/lib/Response.php index d3adbbc..24454c6 100644 --- a/lib/Response.php +++ b/lib/Response.php @@ -36,7 +36,6 @@ class Response extends Message implements ResponseInterface { 303 => 'See Other', 304 => 'Not Modified', 305 => 'Use Proxy', - 306 => 'Reserved', 307 => 'Temporary Redirect', 308 => 'Permanent Redirect', 400 => 'Bad Request', From acb39bb948985e38808adc9b96e5ccad05294c3d Mon Sep 17 00:00:00 2001 From: Evert Pot Date: Wed, 3 Dec 2014 01:01:21 -0500 Subject: [PATCH 19/19] Releasing this extremely minor update. --- ChangeLog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 7873d94..1437565 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,7 +1,7 @@ ChangeLog ========= -3.0.3 (????-??-??) +3.0.3 (2014-12-03) ------------------ * Hiding `Authorization` header value from `Request::__toString`.