Giter VIP home page Giter VIP logo

psr-http's Introduction

psr-http's People

Contributors

terrylinooo avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

psr-http's Issues

Incorrect implementation of \Shieldon\Psr17\RequestFactory::createRequest

This is the official interface declaration from psr/http-factory

namespace Psr\Http\Message;

interface RequestFactoryInterface
{
    /**
     * Create a new request.
     *
     * @param string $method The HTTP method associated with the request.
     * @param UriInterface|string $uri The URI associated with the request. If
     *     the value is a string, the factory MUST create a UriInterface
     *     instance based on it.
     *
     * @return RequestInterface
     */
    public function createRequest(string $method, $uri): RequestInterface;
}

As you can is in the comment for $uri parameter it can be either string or UriInterface. Your implementation assumes string only. I think it should be fixed.

Response reason-phrase validation

https://github.com/terrylinooo/psr-http/blob/master/src/Psr7/Response.php#L257-L262

I don't think this does what it's intended to do.

$escapeChars = [
    '\f', '\r', '\n', '\t', '\v', '\0', '[\b]',
    '\s', '\S', '\w', '\W', '\d', '\D', '\b', '\B', '\cX', '\xhh', '\uhhhh',
];
$filteredPhrase = \str_replace($escapeChars, '', $phrase);

The code is testing/replacing those string literals / not the characters they represent.
(preg_replace is being confused with str_replace?)

The test case is also invalid
https://github.com/terrylinooo/psr-http/blob/master/tests/Psr7/ResponseTest.php#L77
'\n` and '\r' are in the test string... not "\n" and "\r"

Here's an example of a phrase that should not be allowed:

 $response = new \Shieldon\Psr7\Response();
 $response->withStatus(200, "This reason is invalid\r\nIt should not be allowed");  // this should throw an exception.  It does not

that said, here's how the reason-phrase is defined:
https://datatracker.ietf.org/doc/html/rfc7230#section-3.1.2

reason-phrase = *( HTAB / SP / VCHAR / obs-text )

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.