educoder / pest

A proper REST client for PHP.
356 stars 123 forks source link

response headers handling - same key, different values #57

Open dneves opened 10 years ago

dneves commented 10 years ago

If the server sends 2 or more headers with the same key, the last_headers array contains only the last header sent from the server in the corresponding key.

for example, if the server sends 2 http Link headers in the response, Link: <SOME_URL>; rel="REL_NAME" Link: <SOME_SECOND_URL>; rel="SECOND_REL_NAME" , only the second is saved in the Pest.last_headers array :

private function handle_header($ch, $str) {
        if (preg_match('/([^:]+):\s(.+)/m', $str, $match)) {
            $this->last_headers[strtolower($match[1])] = trim($match[2]);
        }
        return strlen($str);
    }

this handler replaces headers with the same name.

if i make the same request directly in chrome, in the network tab i can see it parses all headers...

do you have any plans on fixing this ?

Thank you.