I have a curl command like below (sample one)
curl -v https://my-ip/sample/v1/map/1?name=sat&id=123&code=AE123, ER345
When I execute above curl command directly its giving complete response(contains more than 2 pages) but when I am executing the above curl in java using AsyncHttpClient
it is giving 2 lines of response only. Sample Code
private static void executeHttps(String map, String codes) throws ExecutionException, InterruptedException, IOException {
AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
String url = "https://my-ip/sample/v1/map/"+channelMap;
AsyncHttpClient.BoundRequestBuilder r = asyncHttpClient.prepareGet(url);
r.addQueryParam("name", "sat");
r.addQueryParam("id", "123");
r.addQueryParam("codes", codes);
logger.info("URL: "+r);
Future<Response> f = r.execute();
Response res = f.get();
logger.info(res.getStatusCode() + ": " + res.getStatusText());
logger.info(res.getResponseBody());
}
I also tried to implement the code which will directly execute as a curl command in java i.e
String curlString = "curl -v https://my-ip/sample/v1/map/1?name=sat&id=123&code=AE123, ER345";
Process process = Runtime.getRuntime().exec(curlString);
InputStream is = process.getInputStream();
String s = jsonString = IOUtils.toString(is, StandardCharsets.UTF_8);
JSONObject json = new JSONObject(s);
When I print json
value it is giving the same response as AsyncHttpClient
. Not able to get actual response in both the cases. Here another point is when I change codes
values in the curl
command I will get different response(for some codes I am getting same response in direct curl and in program but for codes getting different responses in direct curl and program curl).
I also tried to use HttpUrlConnection
and HttpsUrlConnection
but still facing same issue