Hello. To send requests via the https protocol, I use the following code:

public String HTTPSPost(String url, User entity) throws Exception { String body = new ObjectMapper().writeValueAsString(entity); URL link = new URL(url); HttpsURLConnection connection = (HttpsURLConnection) link.openConnection(); connection.setDoOutput(true); connection.setRequestMethod("POST"); connection.setRequestProperty("Content-type", "application/json"); OutputStream outputStream = connection.getOutputStream(); outputStream.write(body.getBytes()); InputStream inputStream = connection.getInputStream(); InputStreamReader inputStreamReader = new InputStreamReader(inputStream); BufferedReader br = new BufferedReader(inputStreamReader); StringBuffer responseObject = new StringBuffer(); String inputLine; while ((inputLine = br.readLine()) != null) { System.out.println(inputLine); responseObject.append(inputLine); } String response = new ObjectMapper().readValue(inputStream, String.class); } 

In response, I can receive both text and json objects. In any of these cases, I need to get a String body, but not in the same way as in the above code, but at a lower resource and time cost. That is, if I receive a response of 2 MB in size, then a lot of time and resources will be spent on trying to get an answer, that is, while, which is absolutely not suitable for me. I just need to get the answer body. And one more thing - ObjectMapper maps a json object when passing a reference to the class of this object, but I need to receive this json object as text, but I don’t understand how I do it. Thanks for any replies.

    0