我有一个调用本地tomcat REST服务器的php REST客户端,并且在过去几年中一直在生产服务器上使用它。
我必须进行一些不相关的客户端CSS更改,并且必须构建我的开发环境以测试他们在推送产品之前是否正常。由于我已经安装了流浪者版本的一些变化,我必须更改它使用的流浪盒,我认为这是导致所有问题的原因。
当我发出cURL请求时,会出现一些奇怪的事情并且它没有正确创建请求。
这是我的客户代码(目前正在制作):
class RestClient {
private $baseEndpoint;
private $username;
private $password;
private $siteCode;
function __construct($baseEndpoint, $username, $password, $siteCode) {
$this -> baseEndpoint = $baseEndpoint;
$this -> username = $username;
$this -> password = $password;
$this -> siteCode = $siteCode;
}
public function get($endpoint) {
//die($this -> baseEndpoint . $endpoint); //comment1
$curlResource = curl_init($this -> baseEndpoint . $endpoint);
curl_setopt_array($curlResource, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTPHEADER => array(
"Accept:application/json",
"Content-Type:application/json",
"Site-Code:" . $this -> siteCode,
),
CURLOPT_USERPWD => $this -> username . ":" . $this -> password
));
$curlResponse = curl_exec($curlResource);
// echo curl_error($curlResource); //comment2
$resultStatus = curl_getinfo($curlResource);
// print_r($resultStatus); die(); //comment3
$statusCode = $resultStatus['http_code'];
if($statusCode != 200) {
throw new Exception("500");
}
$restResponse = new Response();
$restResponse -> setStatus($statusCode);
$restResponse -> setEntity($curlResponse);
return $restResponse;
}
有些人注意到:
cURL support enabled
cURL Information 7.19.7
Age 3
Features
AsynchDNS No
CharConv No
Debug No
GSS-Negotiate Yes
IDN Yes
IPv6 Yes
krb4 No
Largefile Yes
libz Yes
NTLM Yes
SPNEGO No
SSL Yes
SSPI No
Protocols tftp, ftp, telnet, dict, ldap, ldaps, http, file, https, ftps, scp, sftp
Host x86_64-redhat-linux-gnu
SSL Version NSS/3.21 Basic ECC
ZLib Version 1.2.3
libSSH Version libssh2/1.4.2
答案 0 :(得分:1)
https://wiki.centos.org/TipsAndTricks/SelinuxBooleans
setsebool httpd_can_network_connect=1