Closed (fixed)
Project:
Drupal core
Version:
5.x-dev
Component:
base system
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
17 Apr 2007 at 21:02 UTC
Updated:
3 May 2007 at 02:16 UTC
Jump to comment: Most recent file
When Drupal issues an HTTP request using drupal_http_request() and the request fails (for example, you send a request to http://example.com:88 but there is no webserver running on that port) the error code of the response to the fsockopen() call is only preserved by concatenation:
// Make sure the socket opened properly.
if (!$fp) {
$result->error = trim($errno .' '. $errstr);
return $result;
}
IMO, we should be doing
$result->code = $errno;
so that we save the error code separately when the request fails as well as when it succeeds.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | errcode3jv.patch | 1.23 KB | jvandyk |
| #1 | errcode2jv.patch | 558 bytes | jvandyk |
| errcodejv.patch | 552 bytes | jvandyk |
Comments
Comment #1
jvandyk commentedHere's a patch that places the error code in a separate namespace to enforce the checking of isset($result->error) instead of looking only at the result code.
This is only needed if numeric result codes from fsockopen() overlap with HTTP result codes. Anyone know?
Comment #2
dries commentedI can reproduce this problem -- and it breaks some of my XML-RPC code. (Actually, it was me who reported this problem to John.)
If we create two namespaces (one for network/tcp errors and one for HTTP errors), I suggest that we rename the variables/fields to be slightly more intuitive. The names should be somewhat self-explanatory, especially in CVS HEAD where we can break backward compatibility.
The alternative, is to return negative error numbers for network errors and positive error numbers for HTTP errors. Of course, that would modify the original error code, but I don't think we can use these -- and these might not be standard error codes to begin with.
Either solution works for me -- I leave it up to John to decide. :)
Comment #3
jvandyk commentedHere's a simple patch that implements negative result codes. This is the smallest step forward that makes it work.
Comment #4
dries commentedI've tested this and it works. I committed this to CVS HEAD but this needs to be backported to DRUPAL-5 because otherwise xmlrpc_errno() will fail to work properly in certain situations.
Comment #5
drummCommitted to 5.
For your next patch.. try doing xml-rpc to a nonexistent domain, such as distributed login with a nonexistent domain. The error is not too useful, seems like it might even be a random number.
Comment #6
(not verified) commented