I use the following code to request xml from a web server:
HttpClient httpclient = new DefaultHttpClient() try { HttpGet httpget = new HttpGet("http://63.255.173.242/get_public_tbl.cgi?A=1"); ResponseHandler responseHandler = new BasicResponseHandler(); String responseBody = httpclient.execute(httpget, responseHandler); System.out.println(responseBody); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { httpclient.getConnectionManager().shutdown(); }
I get a clientProtocolException when calling httpclient.execute (httpget, responseHandler). The url works fine in a web browser, it returns xml and the browser displays it.
Any ideas why I get a clientProtocolException and yet the browser handles it just fine?
Change 1:
Looking at the protocol exception, a detailed message: "The server could not respond with a valid HTTP response." I cannot change the web server that I click on. Is there a way to ignore this and just access the answer?
Edit 2:
I found that the server is not sending the full header. Is there a way to access the contents of the response even if a damaged header is returned?
Edit 3: I edited the ip address to be the real IP address that I click on. Any help would be greatly appreciated.
source share