Skip to content

Commit 770f403

Browse files
committed
do not reject uppercased HTTP method names
1 parent 6e4de62 commit 770f403

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ CHANGELOG
44
0.3.0
55
-----
66

7+
* Fixed treating HTTP methods case insensitive. Rejecting uppercased HTTP
8+
method names contradicts the HTTP specification. Lowercased method names
9+
will still be supported to keep backwards compatibility though.
10+
711
* Fixed creating `XApiClient` instances in an invalid state. The `XApiClientBuilder`
812
now throws a `\LogicException` when the `build()` method is called before
913
a base URI was configured.

spec/Request/HandlerSpec.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,31 @@ function it_returns_get_request_created_by_the_http_client(ClientInterface $clie
3434
$client->get('/xapi/statements')->willReturn($request);
3535

3636
$this->createRequest('get', '/xapi/statements')->shouldReturn($request);
37+
$this->createRequest('GET', '/xapi/statements')->shouldReturn($request);
3738
}
3839

3940
function it_returns_post_request_created_by_the_http_client(ClientInterface $client, RequestInterface $request)
4041
{
4142
$client->post('/xapi/statements', null, 'body')->willReturn($request);
4243

4344
$this->createRequest('post', '/xapi/statements', array(), 'body')->shouldReturn($request);
45+
$this->createRequest('POST', '/xapi/statements', array(), 'body')->shouldReturn($request);
4446
}
4547

4648
function it_returns_put_request_created_by_the_http_client(ClientInterface $client, RequestInterface $request)
4749
{
4850
$client->put('/xapi/statements', null, 'body')->willReturn($request);
4951

5052
$this->createRequest('put', '/xapi/statements', array(), 'body')->shouldReturn($request);
53+
$this->createRequest('PUT', '/xapi/statements', array(), 'body')->shouldReturn($request);
5154
}
5255

5356
function it_returns_delete_request_created_by_the_http_client(ClientInterface $client, RequestInterface $request)
5457
{
5558
$client->delete('/xapi/statements')->willReturn($request);
5659

5760
$this->createRequest('delete', '/xapi/statements')->shouldReturn($request);
61+
$this->createRequest('DELETE', '/xapi/statements')->shouldReturn($request);
5862
}
5963

6064
function it_throws_an_access_denied_exception_when_a_401_status_code_is_returned(RequestInterface $request, Response $response)

src/Request/Handler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function createRequest($method, $uri, array $urlParameters = array(), $bo
5757
$uri .= '?'.http_build_query($urlParameters);
5858
}
5959

60-
switch ($method) {
60+
switch (strtolower($method)) {
6161
case 'get':
6262
$request = $this->httpClient->get($uri);
6363
break;

0 commit comments

Comments
 (0)