Giter VIP home page Giter VIP logo

Comments (6)

Zegnat avatar Zegnat commented on July 23, 2024

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.

Nyholm avatar Nyholm commented on July 23, 2024

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.

Zegnat avatar Zegnat commented on July 23, 2024

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.

mindplay-dk avatar mindplay-dk commented on July 23, 2024

@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.

mindplay-dk avatar mindplay-dk commented on July 23, 2024

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.

mindplay-dk avatar mindplay-dk commented on July 23, 2024

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)

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.