Code example for HttpURLConnection

Methods: getInputStream, getResponseCode, getResponseMessage

0
	private final String body;
	private final int responseCode;
	private final String responseMessage;
 
	HttpResponse(HttpURLConnection connection) throws IOException {
		responseCode = connection.getResponseCode();
		responseMessage = connection.getResponseMessage();
		InputStream stream = connection.getInputStream();
		try { 
			body = StreamHelper.readStreamContent(stream);
		} finally { 
			stream.close();
		} 
	} 
	/** 
	 * Get http response body 
	 * @return http response body 
	 */ 
	public String getBody() {
		return body;
	}