Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header Problems #77

Closed
geggleto opened this issue Nov 1, 2016 · 5 comments
Closed

Header Problems #77

geggleto opened this issue Nov 1, 2016 · 5 comments
Labels

Comments

@geggleto
Copy link

geggleto commented Nov 1, 2016

Problem:
Array to String Converstion

Description:
PSR-7 dictates the format of the Headers as a key with a collection of header-lines.

Offending Code:
https://github.com/reactphp/http/blob/master/src/Response.php#L85

Reproducible:
Yes

Context:
I was attempting to bridge Slim's PSR-7 HTTP objects into React.

Code:

    try {
        /** @var $slimResponse  Response */
        $slimResponse = $slim($slimRequest, new Response());

        //This below line constructs the React Response with Slim Data
        $response->writeHead($slimResponse->getStatusCode(), $slimResponse->getHeaders());
        $slimResponse->getBody()->rewind();
        $response->end($slimResponse->getBody()->getContents());
    } catch (Exception $e) {
        $response->writeHead(500, array('Content-Type' => 'text/html'));
        $response->end('Internal Server Error');
    }
@clue
Copy link
Member

clue commented Nov 1, 2016

You may want to iterate over your PSR-7 headers and remove one nesting depth so that it's compatible with React's headers. We should probably eventually implement PSR-7, see also #28.

@geggleto
Copy link
Author

geggleto commented Nov 1, 2016

I did manage to get it to work finally :)

https://github.com/geggleto/slim-service-registry/blob/master/app.php

@clue
Copy link
Member

clue commented Nov 1, 2016

Thanks for reporting back and glad you've got this sorted! 👍

I'll assume this is resolved and will close this for now, please feel free to report back otherwise.

@clue clue closed this as completed Nov 1, 2016
@clue clue added the question label Nov 1, 2016
@geggleto
Copy link
Author

geggleto commented Nov 1, 2016

All is good... only suggestion is to hurry up with PSR-7 :P

@cboden
Copy link
Member

cboden commented Nov 3, 2016

Pull requests welcome :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants