我有一个奇怪的问题,我正在两台不同的服务器上进行测试,
我尝试使用 cURL 在该服务器上调用网址,此网址可以返回以下代码之一: 200 , 406 ,带有包含消息的json正文。
在查询Apache服务器时,在406错误时,我得到了这个:
< HTTP/1.1 100 Continue
< HTTP/1.1 406 Not Acceptable
< Date: Wed, 10 Dec 2014 11:16:01 GMT
< Server: Apache/2.4.10 (Ubuntu)
< Content-Length: 75
< Content-Type: application/json
* HTTP error before end of send, stop sending
<
{"status":406,"message":"Domain not found (is the file named correctly ?)"}* Closing connection 0
在查询Zend Server时,我明白了:
< HTTP/1.1 100 Continue
< HTTP/1.1 406 Not Acceptable
< Date: Wed, 10 Dec 2014 11:15:05 GMT
< Connection: Keep-Alive
< Content-Type: text/html; charset=iso-8859-1
< Content-Length: 261
* HTTP error before end of send, stop sending
<
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>406 Not Acceptable</title>
</head><body>
<h1>Not Acceptable</h1>
<p>An appropriate representation of the requested resource /webservice could not be found on this server.</p>
</body></html>
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):
标题类型从application / json更改为text / html,正文是一个普通的html错误页面。
这是Zend服务器问题吗?
答案 0 :(得分:0)
我不认为这是任何服务器的问题。两个服务器返回的错误代码是406,但是http响应主体中的错误消息是作为json发送到apache和html的zend服务器中,因此是不同的内容类型。
两台服务器选择以不同的格式发送错误消息,因此内容类型不同。