This repository has moved to laminas/laminas-psr7bridge.
Code for converting PSR-7 messages to zend-http messages, and vice versa.
PSR-7 <-> zend-http message conversions
License: BSD 3-Clause "New" or "Revised" License
This repository has moved to laminas/laminas-psr7bridge.
Code for converting PSR-7 messages to zend-http messages, and vice versa.
here: https://github.com/zendframework/zend-psr7bridge/blob/master/src/Psr7ServerRequest.php#L112
...
'tmp_name' => $upload->getStream()
...
this should be string
not StreamInterface
because of that zend-validator almost all file validators does not work. Also:
// do request with 1 file
$files = $request->getUploadedFiles(); // returns array with 1 file
$request = Psr7ServerRequest::toZend($request);
$request2 = Psr7ServerRequest::fromZend($request);
$files2 = $request2->getUploadedFiles(); // return empty array
I understand that PSR7 does not have method in interface to retrieve tmp_name
but maybe some kind of workaround could be used?
In Expressive is BodyParamsMiddleware
which handles body parsing (x-www-form-urlencoded
and json
). I think it would be useful to have same function in Psr7ServerRequest
. I can create PR.
When converting a PSR7 Response object that includes a real Stream (a file download, for instance), the conversion reads the entire body and returns a ZendResponse.
This throws a memory exceeded limit in the case of large files. This Is caused by trying to read the entire body of the response instead of passing along a Stream object
Is there a reason why the server params aren't passed to the PSR-7 server request? Should I open a PR?
Since the docs are located elsewhere this repo's empty wiki should be disabled.
Cookies don't seem to be handled at all by Psr7ServerRequest::fromZend()
. Is there a reason for that or is this just not implemented yet?
This bug causes Zend Router to fail when used with Zend Expressive when the index is outside of the server root. The issue is that the scheme://host should not be part of Zend Request requestUri.
//Zend\Request
$this->setRequestUri((string) $uri); //the scheme + host should be removed here
// $this->setRequestUri(preg_replace('#^[^/:]+://[^/]+#', '', $uri));
Test case
use PHPUnit\Framework\TestCase;
use Zend\Diactoros\ServerRequestFactory;
use Zend\Http\PhpEnvironment\Request as ZendRequest;
use Zend\Psr7Bridge\Psr7ServerRequest;
class Bug extends TestCase
{
public function test()
{
$_SERVER = [
'HTTP_HOST' => 'host.com',
'SERVER_PORT' => '80',
'REQUEST_URI' => '/test/path/here/',
'SCRIPT_FILENAME' => '/c/root/test/path/here/index.php',
'PHP_SELF' => '/test/path/here/index.php',
'SCRIPT_NAME' => '/test/path/here/index.php',
];
$psr7 = ServerRequestFactory::fromGlobals();
$converted = Psr7ServerRequest::toZend($psr7);
$zend = new ZendRequest();
$this->assertSame($zend->getBaseUrl(), $converted->getBaseUrl());
}
PHPUnit 6.5.2 by Sebastian Bergmann and contributors.
F 1 / 1 (100%)
Time: 272 ms, Memory: 4.00MB
There was 1 failure:
1) Bug::test
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-'/test/path/here'
+''
tests\Bug.php:27
phpunit\phpunit\phpunit:53
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
thanks :)
\Zend\Psr7Bridge\Psr7ServerRequest::convertUploadedFiles()
tries to access $upload->getStream()
which fails on $upload->getError() !== UPLOAD_ERR_OK
- see \Zend\Diactoros\UploadedFile::getStream()
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.