Goutte
Goutte copied to clipboard
Small Enhancement (http header capitalization)
Hi,
while, technical speaking, the header capitalization doesn't matter, i would like to have the option to have a camel-case-styled headers send to the server. I'd love to have the requests as browser-like as possible.
Example 1 ("bad" aka "what you get now at version 3.2"):
accept-encoding: gzip, deflate
Example 2 ("good"):
Accept-Encoding: gzip, deflate
I made myself a simple helper function to aquire this:
protected function convertHeaderFieldNameToCamelCase($input) {
return mb_convert_case($input, MB_CASE_TITLE, "UTF-8");
}
This function should be called in https://github.com/FriendsOfPHP/Goutte/blob/master/Goutte/Client.php#L152 Something like:
if( true === is_array($requestOptions['headers']) ) {
$tmp_headers = array();
foreach ($requestOptions['headers'] as $name => $value) {
$tmp_headers[$this->convertHeaderFieldNameToCamelCase($name)] = $value;
}
$requestOptions['headers'] = $tmp_headers;
unset($tmp_headers);
}
I can provide a PR, if you want.
As you said, it does not matter. So, not something we need to fix.