-
Notifications
You must be signed in to change notification settings - Fork 43
Exception due to Zencoder response headers being lower-case now #29
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
Comments
The Zencoder API returns Content-Type using that capitalization. Can you provide an example request (with authentication obscured) where you see that happening? It might be that you've got a proxy server or library that's altering the headers. |
We are seeing exactly the same thing with our integration. Since 3-4 days ago, the response headers are all lowercase so it throws the We haven't changed anything on our side that I know of that could have affected this. |
...having said that, when we run the same code on our local testing servers, the headers used are in the correct Upper/Lower case format |
After doing some additional testing, we found that the Zencoder servers indeed return the correct header format (capitalized), by testing on our server with the following command,
So the issue does not appear to be a proxy. However, the curl command used in the zencoder-php library returns lower-case headers. We tested this using the following simplified script: <?php
$ch = curl_init();
curl_setopt_array($ch, array (
CURLOPT_URL => "https://app.zencoder.com/api/v2/outputs/2079092822/progress.json",
CURLOPT_HTTPGET => 1,
CURLOPT_HEADER => 1,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_CONNECTTIMEOUT => 30,
CURLOPT_TIMEOUT => 60,
CURLOPT_SSL_VERIFYPEER => 1,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_HTTPHEADER => array (
"zencoder-api-key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
)
));
$result=curl_exec($ch);
print_r($result);
curl_close($ch); and got the following output (truncated):
(note the lower-case headers) We suspect this might be a problem with a specific PHP and/or curl version, so here are the PHP and curl versions:
Is there a specific PHP 7 version (or curl version) which zencoder-php is verified on, so we can update to that version? |
Looking at this further, the PHP version is using HTTP 2 instead of 1.1, and the HTTP 2 specification requires that headers are lower-cased. So that seems to be what's causing the difference. https://httpwg.org/specs/rfc7540.html#HttpHeaders - "Just as in HTTP/1.x, header field names are strings of ASCII characters that are compared in a case-insensitive fashion. However, header field names MUST be converted to lowercase prior to their encoding in HTTP/2. A request or response containing uppercase header field names MUST be treated as malformed (Section 8.1.2.6)." This library obviously predates HTTP/2 so that wasn't a consideration in the original implementation. But hopefully we can push an update sometime soon that compares in case-insensitive fashion. In the meantime, it looks like the code in this issue is a functional workaround. |
Same issue here with the lowercased header values using PHP 7.2. Would be great to have an updated version which addresses this bug. |
@OlafZwe I've submitted your change as Pull Request: #33 I think it's rather related to curl than PHP version, as I have PHP 5.3 and recent curl, and have lowercased headers in the response.
@zencoder: could somebody make a patch release? |
Fixed in #34 |
Uh oh!
There was an error while loading. Please reload this page.
This most recent zencoder-php SDK throws the following exception as a result of any API requests:
Response header is missing Content-Type
The reason appears to be that the SDK checks for the following response header:
Content-Type
. A recent change to Zencoder appears to have resulted in all response headers being returned in lower case. So the SDK is not finding the newcontent-type
lower case header and throwing the above exception.A quick and dirty fix we applied was to use the following code in the
Services/Zencoder.php
_processResponse($response)
function (line 234):The text was updated successfully, but these errors were encountered: