php-vcr icon indicating copy to clipboard operation
php-vcr copied to clipboard

Empty header inserted for curl requests

Open alnorth opened this issue 9 years ago • 3 comments

I'm having problems using php-vcr with the Dropbox client library. There's a few things which are just simple errors that I'll hunt down and add pull requests for. However, there's one that I don't just want to blindly edit because it's obviously deliberate.

For requests using the curl library an empty string is added to the array of headers. See here: https://github.com/php-vcr/php-vcr/blob/1.2.6/src/VCR/Util/CurlHelper.php#L62. There's no comment explaining why and it's causing some issues for code in the Dropbox client. Is there any reason for the empty string?

(And yeah, the Dropbox client library should have been coded to cope with empty strings as headers, but that's a separate problem)

alnorth avatar Oct 07 '15 14:10 alnorth

As far as I remember that was done because the Guzzle implementation was expecting an empty string.

What issues did you run into with the Dropbox client? Is it this one? https://github.com/dropbox/dropbox-sdk-php

adri avatar Jan 07 '16 19:01 adri

Yes, it's that client. Specifically this line: https://github.com/dropbox/dropbox-sdk-php/blob/9db8328c6c035baa0fee48291bd8bd93bcc714b0/lib/Dropbox/DropboxMetadataHeaderCatcher.php#L52. The substr_compare call fails with the message:

substr_compare(): The start position cannot exceed initial string length

I'll probably submit a PR to them with a fix for that line, but wanted to ask you about the empty header too.

Apologies for not replying sooner, I must have missed the notification somehow.

alnorth avatar Feb 26 '16 16:02 alnorth

@adri @alnorth is it safe to change the empty string? Any tests covering this?

If you give me some more information I can look into it!

renatomefi avatar Oct 17 '16 20:10 renatomefi