terrylinooo / psr-http Goto Github PK
View Code? Open in Web Editor NEWPSR-7, 15, 17 implementation.
License: MIT License
PSR-7, 15, 17 implementation.
License: MIT License
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.
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 )
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.