Error setting errno in drupal_http_request (common.inc)
| Project: | Drupal |
| Version: | 7.x-dev |
| Component: | base system |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Jump to:
Hello,
There is a slight bug in drupal_http_request().
The function uses fsockopen(); in http://au.php.net/manual/en/function.fsockopen.php you read:
errno
If provided, holds the system level error number that occurred in the system-level connect() call.
If the value returned in errno is 0 and the function returned FALSE, it is an indication that the error occurred before the
connect() call. This is most likely due to a problem initializing the socket.
The second sentence is where the problem lies. If you use drupal_http_request() on a NON-EXISTING URL, it will fail - but errno will be 0 and errstr will be empty (the socked wasn't initialized). As a result, for any calling function, $result->error will be '0' (FALSE). No error!
Basically, the code needs to check the condition where fp is NULL *and* errno is 0 - in which case, it needs to create an error "artificially".
This is exactly what my patch does.
It's a 3 liner - it would be great if it were included in 6.x
Bye,
Merc.
| Attachment | Size |
|---|---|
| patch_merc.diff | 422 bytes |

#1
Hi,
...anybody?
Merc.
#2
Hi,
I realise this is not a very important bug, as it doesn't affect many users. However, I do think it has _some_ importance...
Bye,
Merc.
#3
Hi,
I don't like raising a bug's importance.
However, this bug has been sitting here for more than 3 months now. Not a comment, nothing.
Can somebody please look at this? If an URL doesn't work, anybody calling drupal_http_request() on a non-existing URL won't be able to tell that there was a problem at all.
I don't think it's urgent. However, after 3 months, I think it has somehow *become* urgent.
Bye,
Merc.
#4
Patches won't get much review if they are not marked as such.
This looks okay on initial inspection, but needs more spaces to match http://drupal.org/coding-standards
Patches are usually best made against the current development version and then back-ported as necessary.
#5
Hi,
I don't have a Drupal 7 right now.
However, the patch should be exactly the same, since the code has the same bug.
It's easy to just add the 3 lines by hand, in fact.
Please let me know if you will go forwards with this. Since it's such a tiny patch, backporting it to D6 and D5 would be grand!
Merc.