The list of methods to do HTTP Response are organized into topic(s).
long
getResourceLastModified(URLConnection connection) get Resource Last Modified
long modified;
if (connection instanceof JarURLConnection) {
URL jarFileUrl = ((JarURLConnection) connection).getJarFileURL();
URLConnection jarFileConnection = jarFileUrl.openConnection();
try {
modified = jarFileConnection.getLastModified();
} finally {
try {
...
long
getResourceModifiedTime(URL url) Retrieves the last modified time of a provided URL.
long lastModified = 0L;
try {
if (url.getProtocol().equals(JAR_PROTOCOL)) {
JarURLConnection jarConn = (JarURLConnection) url.openConnection();
url = jarConn.getJarFileURL();
if (url.getProtocol().equals(FILE_PROTOCOL)) {
File file;
...
String
getResponse(URL request) get Response
URLConnection yc = request.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
StringBuilder sb = new StringBuilder();
String inputLine;
while ((inputLine = in.readLine()) != null) {
sb.append(inputLine);
in.close();
...
String
getResponse(URL url) Returns the content of the response body for the given url
StringBuffer response = new StringBuffer();
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod(GET);
try (BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
String sCurrentLine;
while ((sCurrentLine = br.readLine()) != null) {
response.append(sCurrentLine);
return response.toString();
String
getResponseAsString(HttpURLConnection conn) get Response As String
String charset = getResponseCharset(conn.getContentType());
InputStream es = conn.getErrorStream();
if (es == null) {
return getStreamAsString(conn.getInputStream(), charset);
} else {
String msg = getStreamAsString(es, charset);
if (isEmpty(msg)) {
throw new IOException(conn.getResponseCode() + ":" + conn.getResponseMessage());
...
String
getResponseBody(HttpURLConnection conn) get Response Body
BufferedReader br = null;
StringBuilder body = null;
String line = "";
try {
br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
body = new StringBuilder();
while ((line = br.readLine()) != null)
body.append(line);
...
String
getResponseContent(HttpURLConnection connection) get Response Content
InputStream is = connection.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String line;
StringBuffer response = new StringBuffer();
try {
while ((line = reader.readLine()) != null) {
response.append(line);
response.append('\n');
...
String
getResponseContent(HttpURLConnection httpConn) Get the response (or error response) as a string
try {
if (httpConn.getInputStream() == null) {
return null;
} else {
StringBuilder sb = new StringBuilder();
BufferedReader in = new BufferedReader(new InputStreamReader(httpConn.getInputStream()));
String str;
while ((str = in.readLine()) != null) {
...
String
getResponseContent(String url) get Response Content
StringBuffer responseString = new StringBuffer();
URLConnection connection = new URL(url).openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String aux;
while ((aux = in.readLine()) != null) {
responseString.append(aux);
in.close();
...