Comments (6)
I was trying to set this up and got to wondering whether it is right to limit ServerRequestCreatorInterface::fromGlobals
to getallheaders
for the HTTP headers?
That method is, generally, only available on Apache servers. Anyone currently using this implementation who cannot guarantee their code will run in an Apache environment will have to do something like I had to do:
$requestCreator = $injector->make(Nyholm\Psr7Server\ServerRequestCreator::class);
$request = $requestCreator->fromArrays(
$_SERVER,
function_exists('getallheaders') ? getallheaders() : $requestCreator->getHeadersFromServer($_SERVER),
$_COOKIE,
$_GET,
$_POST,
$_FILES
);
As the interface is already defining a method for getting headers from globals, why not use that?
On that note, if ServerRequestCreatorInterface::getHeadersFromServer
is supposed to fill the polyfill-for-non-Apache role, would it be better as a static
method? That way it could truly be used as a polyfill in other circumstances too without always having to create a new ServerRequestCreatorInterface
instance.
from psr7-server.
It makes sense to fall back on getHeadersFromServer
if getallheaders()
is not available 👍
Sure, we can declare it static. Would you mind creating a PR?
from psr7-server.
PRs filed, new issue opened. Basically detailing things I personally would have expected ServerRequestCreatorInterface::fromGlobals
to do but found it didn’t do.
from psr7-server.
@Nyholm if I may suggest, just a minor change, but "creator" isn't really the normal terminology - it's a factory, right? I'd rename the class with a Factory suffix, which is consistent with your PSR-17 factory used in the example anyhow. Since upgrading to 1.0.0
is a manual chore anyhow, might as well fix this?
from psr7-server.
oh, wait, I just realized that would conflict with ServerRequestFactoryInterface
in PSR-17.
still, "creator" is unusual terminology - since this isn't actually creating the request, and isn't really a factory either since it depends on the factory, what is it doing? building the server-request maybe? ServerRequestBuilder
then?
Maybe just bikeshedding.
from psr7-server.
Are there any pending issues blocking a 1.0 release?
If so, I'm happy to help. If not... :-)
from psr7-server.
Related Issues (17)
- Should fromGlobals also set the HTTP request body? HOT 1
- Stop using UriFactory HOT 3
- Failed to create UploadedFile when an upload error occurred HOT 2
- Static method in interface? HOT 2
- Duplicated port in URI HOT 3
- Incorrect scheme/port when using a proxy-server HOT 15
- Better Namespaces HOT 3
- Fix tests fixtures
- Header with only numbers seems to cause exception HOT 23
- Empty file upload gives fatal error in PHP 8.0 HOT 1
- Filter headers consisting only of whitespace before creating a ServerRequest HOT 2
- Duplicate host values in Host header when creating a Psr request from globals
- Uri::withPort + numeric strings
- Scheme detection problem
- psr/http-message version issue HOT 4
- Hope support php8.1 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from psr7-server.