Code Monkey home page Code Monkey logo

zend-psr7bridge's Introduction

zend-psr7bridge's People

Contributors

alextartan avatar boesing avatar ezimuel avatar froschdesign avatar harikt avatar koopzington avatar michalbundyra avatar midnightdesign avatar samsonasik avatar svycka avatar weierophinney avatar xerkus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zend-psr7bridge's Issues

does not convert uploaded files correctly

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?

ServerRequest parsedBody do not parse json

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.

Converting Stream responses bug

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

Convert Cookies from Zend to PSR-7

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?

Converted PSR7 request does not return correct baseUrl

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.

Erroneous upload breaks request bridge

\Zend\Psr7Bridge\Psr7ServerRequest::convertUploadedFiles() tries to access $upload->getStream() which fails on $upload->getError() !== UPLOAD_ERR_OK - see \Zend\Diactoros\UploadedFile::getStream().

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.