C
C
champloootaku2017-06-07 13:06:40
PHP
champloootaku, 2017-06-07 13:06:40

Why does Curl 7.22 header have a different response when upgrading to 7.47?

Good day everyone.
I have a code to send headers:

$arr[]='User-Agent: teeeeest';
        $arr[]='Host: '.$host;
        $c = curl_init($url);
        curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($c, CURLOPT_HTTPHEADER, $arr);
        curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0);
        $check = curl_exec($c);

And I get answers in the order I need:
LibCurl 7.22:
(
[Accept] => */*
[User-Agent] => teeeeest
[Host] => answer.site.com
)

But when I update libcurl to 7.47 I get the answer in a different order:
(
[Host] => answer.site.com
[Accept] => */*
[User-Agent] => teeeeest
)

What I need to fix in the \curl code is that the answer would go in the old order. Because it is critical for the application.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2017-06-07
@glebovgin

According to rfc7230, the Host header should always come first. So in 7.22 it was a bug that was fixed and in 7.47 Host comes first, which is correct.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question