我最近从Ubuntu 17.04切换到Windows10。 在Ubuntu我有最新版本的Apache,PHP(已启用PhalconPHP)。
在Windows 10中,我安装了最新版本的XAMPP。 在Windows中,我的所有网站都有奇怪的行为。例如在我的angularJS网站上, 所有$ http请求都返回空响应状态:200(这意味着我的PHP代码中没有错误)。 奇怪的是,当在浏览器URL输入中输入时,相同的URL返回数据。apache error_log:
[Fri Jan 19 11:25:18.900931 2018] [ssl:warn] [pid 10808:tid 640] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Fri Jan 19 11:25:19.027166 2018] [core:warn] [pid 10808:tid 640] AH00098: pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Fri Jan 19 11:25:19.044248 2018] [ssl:warn] [pid 10808:tid 640] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Fri Jan 19 11:25:19.127479 2018] [mpm_winnt:notice] [pid 10808:tid 640] AH00455: Apache/2.4.29 (Win32) OpenSSL/1.1.0g PHP/7.2.1 configured -- resuming normal operations
[Fri Jan 19 11:25:19.127479 2018] [mpm_winnt:notice] [pid 10808:tid 640] AH00456: Apache Lounge VC15 Server built: Nov 3 2017 10:30:36
[Fri Jan 19 11:25:19.127479 2018] [core:notice] [pid 10808:tid 640] AH00094: Command line: 'c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Fri Jan 19 11:25:19.150227 2018] [mpm_winnt:notice] [pid 10808:tid 640] AH00418: Parent: Created child process 5908
[Fri Jan 19 11:25:19.934501 2018] [ssl:warn] [pid 5908:tid 668] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Fri Jan 19 11:25:20.014506 2018] [ssl:warn] [pid 5908:tid 668] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Fri Jan 19 11:25:20.071023 2018] [mpm_winnt:notice] [pid 5908:tid 668] AH00354: Child: Starting 150 worker threads.
以下是我的http工厂:
app.factory('network', ['$http', '$rootScope', function($http, $rootScope) {
var network = {};
network.request = function(addr, params, callback = "", failcallback = ""){
$http({
method: "POST",
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
url: config.server + addr,
transformRequest: function(obj) {
var str = [];
for(var p in obj)
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
return str.join("&");
},
data: params
}).then(
function(response) {
callback(response);
},
function(response) {
if (failcallback){
failcallback(response);
}
});
}
return network;
}]);
可以在控制器中调用网络工厂:
network.request("/some-action-url", {
data
}, function(response){
if (response.data.status == "OK"){
// do something
} else {
// get error from server
}
});
我认为我的代码没有问题,因为它在我拥有的Ubuntu上运行良好。 apache,php或windows设置可能有问题。