Skip to content

Commit

Permalink
Merge pull request #618 from brefphp/fix-missing-dependency
Browse files Browse the repository at this point in the history
Fix missing dependency for PSR-15 handlers
  • Loading branch information
mnapoli authored Apr 12, 2020
2 parents 43de25e + d8e9c79 commit edf500c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"riverline/multipart-parser": "^2.0.6",
"psr/http-server-handler": "^1.0",
"async-aws/cloud-formation": "^0.4",
"async-aws/lambda": "^0.4"
"async-aws/lambda": "^0.4",
"nyholm/psr7": "^1.2"
},
"require-dev": {
"phpunit/phpunit": "^6.5",
Expand Down
14 changes: 11 additions & 3 deletions src/Event/Http/Psr7Bridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
namespace Bref\Event\Http;

use Bref\Context\Context;
use GuzzleHttp\Psr7\ServerRequest;
use GuzzleHttp\Psr7\UploadedFile;
use Nyholm\Psr7\ServerRequest;
use Nyholm\Psr7\Stream;
use Nyholm\Psr7\UploadedFile;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Riverline\MultiPartParser\Part;
Expand Down Expand Up @@ -39,11 +40,18 @@ public static function convertRequest(HttpRequestEvent $event, Context $context)
$server['HTTP_HOST'] = $headers['Host'];
}

/**
* Nyholm/psr7 does not rewind body streams, we do it manually
* so that users can fetch the content of the body directly.
*/
$bodyStream = Stream::create($event->getBody());
$bodyStream->rewind();

$request = new ServerRequest(
$event->getMethod(),
$event->getUri(),
$event->getHeaders(),
$event->getBody(),
$bodyStream,
$event->getProtocolVersion(),
$server
);
Expand Down

0 comments on commit edf500c

Please sign in to comment.