Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F112681461
HTTPFutureResponseStatusCURL.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, May 12, 06:20
Size
3 KB
Mime Type
text/x-php
Expires
Wed, May 14, 06:20 (2 d)
Engine
blob
Format
Raw Data
Handle
26127494
Attached To
rPHU libphutil
HTTPFutureResponseStatusCURL.php
View Options
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group futures
*/
final
class
HTTPFutureResponseStatusCURL
extends
HTTPFutureResponseStatus
{
protected
function
getErrorCodeType
(
$code
)
{
return
'cURL'
;
}
public
function
isError
()
{
return
true
;
}
public
function
isTimeout
()
{
// NOTE: The PHP error constant for this is nonsensical (this is not an
// error):
//
// PHP: CURLE_OPERATION_TIMEOUTED
// cURL: CURLE_OPERATION_TIMEDOUT
return
(
$this
->
getStatusCode
()
==
CURLE_OPERATION_TIMEOUTED
);
}
protected
function
getErrorCodeDescription
(
$code
)
{
$constants
=
get_defined_constants
();
$constant_name
=
null
;
foreach
(
$constants
as
$constant
=>
$value
)
{
if
(
$value
==
$code
&&
preg_match
(
'/^CURLE_/'
,
$constant
))
{
$constant_name
=
'<'
.
$constant
.
'> '
;
break
;
}
}
$map
=
array
(
CURLE_COULDNT_RESOLVE_HOST
=>
'There was an error resolving the server hostname. Check that you are '
.
'connected to the internet and that DNS is correctly configured. (Did '
.
'you add the domain to `/etc/hosts` on some other machine, but not '
.
'this one?)'
,
CURLE_SSL_CACERT
=>
'There was an error verifying the SSL Certificate Authority while '
.
'negotiating the SSL connection. This usually indicates that you are '
.
'using a self-signed certificate but have not added your CA to the '
.
'CA bundle. See instructions in "libphutil/resources/ssl/README".'
,
// Apparently there's no error constant for this? In cURL it's
// CURLE_SSL_CACERT_BADFILE but there's no corresponding constant in
// PHP.
77
=>
'The SSL CA Bundle "libphutil/resources/ssl/custom.pem" could not '
.
'be read or is not formatted correctly.'
,
CURLE_SSL_CONNECT_ERROR
=>
'There was an error negotiating the SSL connection. This usually '
.
'indicates that the remote host has a bad SSL certificate, or your '
.
'local host has some sort of SSL misconfiguration which prevents it '
.
'from accepting the CA. If you are using a self-signed certificate, '
.
'see instructions in "libphutil/resources/ssl/README".'
,
CURLE_OPERATION_TIMEOUTED
=>
'The request took too long to complete.'
,
CURLE_SSL_PEER_CERTIFICATE
=>
'There was an error verifying the SSL connection. This usually '
.
'indicates that the remote host has an SSL certificate for a '
.
'different domain name than you are connecting with. Make sure the '
.
'certificate you have installed is signed for the correct domain.'
,
);
$default_message
=
"The cURL library raised an error while making a request. You may be "
.
"able to find more information about this error (error code: {$code}) "
.
"on the cURL site: http://curl.haxx.se/libcurl/c/libcurl-errors.html"
;
$detailed_message
=
idx
(
$map
,
$code
,
$default_message
);
return
$constant_name
.
$detailed_message
;
}
}
Event Timeline
Log In to Comment