The same http code as in json response

classic Classic list List threaded Threaded
3 messages Options
artems artems
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

The same http code as in json response

Hi all!

Example:
jolokia response
{code}
{"request": ..... "error":"java.lang.RuntimeException : tested","status":500}
{code}

but http response code = 200.
example:
{code}
Request URL:http://localhost:8000/jolokia/exec/.....HealthCheck/check
Request Method:GET
Status Code:200 OK
{code}

Maybe will be better to return the same http code as for status?
What do you think about such feature?
artems artems
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: The same http code as in json response

Jolokia forum is dead
roland roland
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: The same http code as in json response

You are somewhat right ;-) Since I'm typically the only answering questions, I do it in bulk once a month or so. Your chances are better when opening issue on Github (but no guarantees ;-)

To your question:

That the HTTP status code and the status code contained in the response is by intention because they serve different purposes:

* HTTP Status Code described the status of the *HTTP transport*
* Response status code describes the status of the *local JMX query*

So its perfectly valid that e.g. when your jMX query fails that the response status code is != 200 but this error message could be perfectly delivered because there was no error on the Jolokia side (hence HTTP code is 200). it would be also hard to map JMX errors to semantic HTTP codes for an general purpose agent like Jolokia.

It cannot said often enough that Jolokia is not REST. The decision about the status code has been done a long time ago and in hindsight tbh, I maybe won't do it the same way (but then, on the other hand, why providing an response status at all when its always the same as the HTTP status ?). However for backwards compatibility (which is a major design goal), I will leave it as it is.

This is also explained in detail in the reference manual : https://jolokia.org/reference/html/protocol.html#responses
... roland
Loading...