Skip to content

Commit

Permalink
Merge pull request #49 from svycka/patch-1
Browse files Browse the repository at this point in the history
set request method
  • Loading branch information
chadicus authored Jan 22, 2020
2 parents 4c2bb3a + 8d383c8 commit 5f64852
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/RequestBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final public static function toOAuth2(ServerRequestInterface $request)
$request->getAttributes(),
$request->getCookieParams(),
self::convertUploadedFiles($request->getUploadedFiles()),
$request->getServerParams(),
array_merge($request->getServerParams(), ['REQUEST_METHOD' => $request->getMethod()]),
$contents,
self::cleanupHeaders($request->getHeaders())
);
Expand Down
20 changes: 20 additions & 0 deletions tests/RequestBridgeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,24 @@ public function toOAuth2WithMultipleFiles()
$oauth2Request->files
);
}

/**
* Verify that sets request method.
*
* @test
* @covers ::toOAuth2
*
* @return void
*/
public function toOAuth2RequestMethodPreserved()
{
$uri = 'https://example.com/foos';

$psr7Request = new ServerRequest([], [], $uri, 'POST', 'php://input');

$oauth2Request = RequestBridge::toOAuth2($psr7Request);

$this->assertSame('POST', $psr7Request->getMethod());
$this->assertSame('POST', $oauth2Request->server('REQUEST_METHOD'));
}
}

0 comments on commit 5f64852

Please sign in to comment.