Returning custom body with HTTP status error

437 Views Asked by At

I have a strange problem, I am testing on two different servers,

  • first server with a basic apache
  • second server with Zend Server

What I am trying to do it's to call an url on that server with cURL, this url can return one of the following codes: 200, 406 with a json body containing a message.

When querying the Apache server, on 406 error, I get this:

< 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

And when querying the Zend Server, I get this:

< 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):

The header type is changed to text/html from application/json, and the body is a plain html error page.

Is this a Zend server issue ?

1

There are 1 best solutions below

0
On

I dont think it is an issue with either server. The error code returned by both the servers is 406 but the error message in the http response body is sent as json in apache and html in zend server, hence the different content-types.

The two servers have chosen to send the error message in different formats hence the diffent content-types.