Opened 12 years ago
Closed 12 years ago
#23310 closed defect (bug) (fixed)
WP_Http_Curl doesn't return errors for non-blocking requests
Reported by: | SergeyBiryukov | Owned by: | dd32 |
---|---|---|---|
Milestone: | 3.6 | Priority: | normal |
Severity: | normal | Version: | |
Component: | HTTP API | Keywords: | has-patch |
Focuses: | Cc: |
Description
Noticed while debugging #23133.
If a server blocks local connections, WP_Http_Streams
and WP_Http_Fsockopen
return errors for both blocking and non-blocking requests:
WP_Http_Streams: Could not open handle for fopen() to ... WP_Http_Fsockopen: "110: Connection timed out"
WP_Http_Curl
, however, just returns an empty response, which makes debugging more difficult:
http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/class-http.php#L1145
The actual error message that curl_error()
returned was "couldn't connect to host".
Attachments (1)
Change History (6)
#2
follow-up:
↓ 3
@
12 years ago
How long does the functions take to execute with that change? I mean, Does the function still return almost instantly, or does it sit around and wait for the HTTP connection to do something?
#3
in reply to:
↑ 2
@
12 years ago
Replying to dd32:
How long does the functions take to execute with that change? I mean, Does the function still return almost instantly, or does it sit around and wait for the HTTP connection to do something?
AFAIK, curl_error()
will only give you the connection errors when using non-blocking requests, so it's only an instant socket error. I haven't tested this thoroughly though.
#4
@
12 years ago
- Milestone changed from Awaiting Review to 3.6
Until we support proper non-blocking curl requests, this seems sane and brings it in line with the other transports. It doesn't appear to affect the response times (curl still parses the response before returning in either case, so we might as well use the output).
23310.patch also closes the handle before returning from the function, which seems the correct thing to do, according to the example on http://php.net/manual/en/function.curl-error.php.