I've been trying to use httprl to talk HTTPS on port 443 to a third party API, but I'm afraid I've failed. If I use HTTP it's fine but HTTPS connections appear to have a bug somewhere deeper than I tried to find.
The symptom was $chunk = fread($r, $responses[$id]->chunk_size); would be empty, as would $responses[$id]->headers - the end result being I couldn't see the response HTTP codes or the data. The data took two chunks to return when it worked.
The issue was intermittent, I'm not sure if the response was lost or if it wasn't sent. After trying to debug it for a while I switched over to cURL. It seems to only be an issue with HTTPS - HTTP worked fine the whole time.
(I was running the patch in issue #1351238 at the same time)
Comment | File | Size | Author |
---|---|---|---|
#6 | httprl-1354282-6.patch | 1008 bytes | mikeytown2 |
Comments
Comment #1
mikeytown2 CreditAttribution: mikeytown2 commented@serenecloud
Do you have the same HTTPS issues with core's drupal_http_request()?
Comment #2
serenecloud CreditAttribution: serenecloud commentedNo, I'm afraid not. I stopped using drupal_http_request because I needed the ability to properly set a timeout time, not because of any issues with the data.
Comment #3
mikeytown2 CreditAttribution: mikeytown2 commentedIs there a https site I can test this with?
Comment #4
mikeytown2 CreditAttribution: mikeytown2 commentedMy guess is the 'eof' attribute is getting incorrectly set http://php.net/stream-get-meta-data.
From http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_ht...
Due to PHP bugs like http://bugs.php.net/bug.php?id=43782 and http://bugs.php.net/bug.php?id=46049 we can't rely on feof(), but instead must invoke stream_get_meta_data() each iteration.
I could try http://php.net/feof as the connection is set to closed in httprl.
Comment #5
serenecloud CreditAttribution: serenecloud commentedThe API I've been pointing at is https://api.nzpost.co.nz/tracking If you click the link in "A sample request is available by clicking here." on that page it'll populate the form for you including a guest license key. I've been using JSON to talk to it.
It sounds like you're getting further than I did to finding a solution :) I'll be able to find a bit of time to test a patch for this, but it won't be until about this time next week, I'm coming up against some hard deadlines.
Some different tracking numbers: RA121779505CN, SA547532703NZ, UE131315957NZ and RQ106421698NZ
Comment #6
mikeytown2 CreditAttribution: mikeytown2 commentedHere's a patch for you to test. I haven't seen it stall till a timeout occurred so that's good.
Comment #7
mikeytown2 CreditAttribution: mikeytown2 commentedAbove patch has been committed.