note 64083 rejected from function.curl-setopt by bjori
| From: | bjori@php.net | Date: | Fri, 07 Apr 2006 06:58:48 +0000 |
| Subject: | note 64083 rejected from function.curl-setopt by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-107485@lists.php.net to get a copy of this message | ||
Note Submitter: ceo at l-i-e dot com
----
If the data you are getting is BINARY, such as, say, a JPEG image, then you need to use
CURLOPT_BINARYTRANSFER.
Otherwise PHP/curl will return what seems to be a valid JPEG, and you can even view it in a browser,
but, in reality, PHP/curl will have corrupted the JPEG.
I'm not sure if it stops at the NULL character, or if it does CRLF conversion or what, but if
you try to use it in, say, imagecreatefromstring() you are going to have problems.
Sometimes I got error messages saying "Not a JPEG." and listing some bytes that were known
to be wrong.
More often, I got segfaults. :-(
The truly weird thing, to my mind, is that browsers are tolerant enough to show you a perfectly fine
image if you dump the data to a file and look at it.
I must have spent an hour or two trying to figure this out.
Hopefully, now you'll find this note and save yourself that hour.