I have a java stand-alone application that exposes two methods through an interface: get - to make GET requests to a URL, and post - to make POST requests to a URL. I am using pure Java for implementing the methods (no Apache HTTP client).
My problem is that on HTTP error returns from the server, I get an IOException client-side (for all codes >= 400). It's little point in arguing whether this is a correct behavior (IMHO it's not). Anyway, I would need to check whether the IOException was caused by a connection problem, or by an HTTP error, as I have to implement different behaviors for these two situations. Does anyone know a decent solution to check this? (by decent I mean not ahving to check for the exception message "Server returned HTTP response code")
Any ideas are really appreciated.
Thanks.