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

Multiple headers with the same name #59

Open
DCzajkowski opened this issue Feb 7, 2018 · 4 comments
Open

Multiple headers with the same name #59

DCzajkowski opened this issue Feb 7, 2018 · 4 comments

Comments

@DCzajkowski
Copy link

DCzajkowski commented Feb 7, 2018

I am trying to connect to a server that returns three headers with the same name: Set-Cookie. When I do a simple

dd(Zttp::asFormParams()->post($url, [
    // some data
])->headers()->toArray());

it returns an array of headers, but Set-Cookie is only one there.

Expected: There should be an array of cookies returned:

[
    'Set-Cookie' => [
        'cookie-1',
        'cookie-2'
    ],
    // some other data
]

Actual: Only first cookie is returned

[
    'Set-Cookie' => 'cookie-1',
    // some other data
]
@DCzajkowski
Copy link
Author

I should note that

$response->header('Set-Cookie')

works as expected by creating a comma-separated list :)

@Vasiliy-Bondarenko
Copy link

I run into the same problem. Took me quite some time to figure it out.

@owenvoke
Copy link

Is this just the use of $v[0] instead of return [$k => $v]; which is causing this?

zttp/src/Zttp.php

Lines 270 to 275 in 39f84d0

function headers()
{
return collect($this->response->getHeaders())->mapWithKeys(function ($v, $k) {
return [$k => $v[0]];
})->all();
}

@Vasiliy-Bondarenko
Copy link

@pxgamer this is one way to solve it. but it's a breaking change :) it will convert all values into arrays of strings instead of just strings.
i did it exactly this way, but now i can't update the package. which is fine in my case.

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

No branches or pull requests

3 participants