GETs content from URL.
@param url url to get from.
@param response response to store url and response value in.
169930
public void doGet(String url, HttpResponse response, boolean followRedirect) {
        doGet(url, response, null, followRedirect);
    }
61276
@Override
  public String content() {
    try (ResponseBody body = okResponse.body()) {
      return body.string();
    } catch (IOException e) {
      throw fail(e);
    }
  }
1210967
public static void redirect(HttpServletRequest request, HttpServletResponse response,
                               String url) throws IOException {
        String redirectUrl;

        if (url.startsWith("/")) {
            redirectUrl = request.getContextPath() + url;
        } else {
            redirectUrl = url;
        }

        logger.debug("Redirecting to URL: {}", redirectUrl);

        response.sendRedirect(redirectUrl);
    }
632802
public static String readUrlContent( String url )
	throws IOException, URISyntaxException {

		InputStream in = null;
		try {
			URI uri = UriUtils.urlToUri( url );
			in = uri.toURL().openStream();
			ByteArrayOutputStream os = new ByteArrayOutputStream();

			Utils.copyStreamSafely( in, os );
			return os.toString( "UTF-8" );

		} finally {
			closeQuietly( in );
		}
	}
873363
private String getContent(String url) throws RottenTomatoesException {
        LOG.trace("Requesting: {}", url);
        try {
            final HttpGet httpGet = new HttpGet(url);
            httpGet.addHeader("accept", "application/json");
            final DigestedResponse response = DigestedResponseReader.requestContent(httpClient, httpGet, charset);

            if (response.getStatusCode() >= HTTP_STATUS_500) {
                throw new RottenTomatoesException(ApiExceptionType.HTTP_503_ERROR, response.getContent(), response.getStatusCode(), url);
            } else if (response.getStatusCode() >= HTTP_STATUS_300) {
                throw new RottenTomatoesException(ApiExceptionType.HTTP_404_ERROR, response.getContent(), response.getStatusCode(), url);
            }

            return response.getContent();
        } catch (IOException ex) {
            throw new RottenTomatoesException(ApiExceptionType.CONNECTION_ERROR, "Error retrieving URL", url, ex);
        }
    }
73895
public String simpleGet(String url) throws IOException {
		final AtomicReference<String> str = new AtomicReference<>();
		simpleGetInternal(url, inputStream -> {
            try {
                str.set(IOUtils.toString(inputStream, "UTF-8"));
            } catch (IOException e) {
                throw new IllegalStateException(e);
            }
        }, null);

		return str.get();
	}
1023612
@Override
	public void getResponse(URI uri, int responseCode, String mimetype,
			String content, String eTag) {
		tracer.info("getResponse(" + uri + ", " + responseCode + ", "
				+ mimetype + ", " + content + ", " + eTag + ")");
	}
1306756
@SuppressWarnings({"squid:S3776", "squid:S2093"})
    private Response getResponse(HttpURLConnection connection) {
        int status;
        Map headers;
        try {
            status = connection.getResponseCode();
            headers = connection.getHeaderFields();
        } catch (IOException e) {
            log.error(e);
            return null;
        }
        JsonObject object = null;
        JsonArray array = null;
        String data = null;
        BufferedReader rd = null;
        // unable to use the try-with-resources block, as the rd needs to be read in the finally, and can't be closed
        try {
            rd = new BufferedReader(new InputStreamReader(connection.getInputStream()));
        } catch (IOException e) {
            log.warn(e);
            try {
                rd = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
            } catch (NullPointerException ee) {
                log.warn(ee);
            }
        } finally {
            StringBuilder sb = new StringBuilder();
            String line;
            if (rd != null) {
                try {
                    while ((line = rd.readLine()) != null) {
                        sb.append(line);
                    }
                } catch (IOException e) {
                    log.error(e);
                }
                try {
                    rd.close();
                } catch (IOException e) {
                    log.error(e);
                }
                data = sb.toString();
                JsonParser parser = new JsonParser();
                try {
                    object = (JsonObject) parser.parse(data);
                } catch (JsonSyntaxException | ClassCastException e) {
                    log.debug(e);
                    try {
                        array = (JsonArray) parser.parse(data);
                    } catch (JsonSyntaxException | ClassCastException ee) {
                        log.debug(ee);
                    }
                }
            }
        }
        return new Response(reporter, headers, status, object, array, data);
    }
602383
public void put(String url, String result) {
        if (TextUtils.isEmpty(url)) {
            return;
        }

        ContentValues contentValues = new ContentValues();
        contentValues.put(OfflinerDBHelper.REQUEST_RESULT, result);
        contentValues.put(OfflinerDBHelper.REQUEST_URL, url);
        contentValues.put(OfflinerDBHelper.REQUEST_TIMESTAMP, Calendar.getInstance().getTime().getTime());

        this.startQuery(
                TOKEN_CHECK_SAVED_STATUS,
                contentValues,
                getUri(OfflinerDBHelper.TABLE_CACHE),
                OfflinerDBHelper.PARAMS_CACHE,
                OfflinerDBHelper.REQUEST_URL + " = '" + url + "'",
                null,
                null
        );
    }
92604
public static HttpServletResponse getEncodingResponse(
            HttpServletResponse response, String charset) {
        response.setCharacterEncoding(charset);
        response.setContentType("text/html;charset=" + charset);
        return response;
    }
627494
private static byte[] requestWebContent(String url) throws TVRageException {
        try {
            HttpGet httpGet = new HttpGet(url);
            httpGet.addHeader("accept", "application/xml");
            final DigestedResponse response = DigestedResponseReader.requestContent(httpClient, httpGet, CHARSET);

            if (response.getStatusCode() >= 500) {
                throw new TVRageException(ApiExceptionType.HTTP_503_ERROR, url);
            } else if (response.getStatusCode() >= 300) {
                throw new TVRageException(ApiExceptionType.HTTP_404_ERROR, url);
            }

            return response.getContent().getBytes(DEFAULT_CHARSET);
        } catch (IOException ex) {
            throw new TVRageException(ApiExceptionType.MAPPING_FAILED, UNABLE_TO_PARSE, url, ex);
        }
    }
727161
public static HttpResponse getResponse(String urls, HttpRequest request,
                                           HttpMethod method, int connectTimeoutMillis, int readTimeoutMillis) throws IOException {
        OutputStream out = null;
        InputStream content = null;
        HttpResponse response = null;
        HttpURLConnection httpConn = request
            .getHttpConnection(urls, method.name());
        httpConn.setConnectTimeout(connectTimeoutMillis);
        httpConn.setReadTimeout(readTimeoutMillis);

        try {
            httpConn.connect();
            if (null != request.getPayload() && request.getPayload().length > 0) {
                out = httpConn.getOutputStream();
                out.write(request.getPayload());
            }
            content = httpConn.getInputStream();
            response = new HttpResponse();
            parseHttpConn(response, httpConn, content);
            return response;
        } catch (SocketTimeoutException e) {
            throw e;
        } catch (IOException e) {
            content = httpConn.getErrorStream();
            response = new HttpResponse();
            parseHttpConn(response, httpConn, content);
            return response;
        } finally {
            if (content != null) {
                content.close();
            }
            httpConn.disconnect();
        }
    }
423638
private void writeNoContentResponse(final HttpServletResponse response) throws IOException {
		response.setStatus(HttpServletResponse.SC_NO_CONTENT);
		response.setContentType("image/gif");

		final PrintWriter out = response.getWriter();
		out.flush();
	}
846915
protected void receiveClientResponse(HttpMessage response) {
        runner.http(action -> {
            HttpClientResponseActionBuilder responseBuilder = action.client(httpClient).receive()
                .response(response.getStatusCode())
                .message(response);

            for (Map.Entry<String, String> headerEntry : pathValidations.entrySet()) {
                responseBuilder.validate(headerEntry.getKey(), headerEntry.getValue());
            }
            pathValidations.clear();
        });
    }
6864
private void streamContent(HttpServletResponse response, InputStream is) throws IOException {

        OutputStream os = response.getOutputStream();
        try {
            byte buffer[] = new byte[DEFAULT_BUFFER_SIZE];
            int bytes;
            while ((bytes = is.read(buffer)) >= 0) {
                os.write(buffer, 0, bytes);
            }
        } finally {
            os.close();
        }
    }
1054938
public static String getContentAsString(HttpResponse response) {

		try {
			if (response != null && response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {

				HttpEntity entity = response.getEntity();
				Header contentEncoding = entity.getContentEncoding();
				String encoding = contentEncoding != null ? contentEncoding.getValue() : UTF_8;
				return ResourceUtils.getString(entity.getContent(), encoding);
			}
		}
		catch (IOException e) {
			log.error("Failed to read response: ", e.getMessage());
		}

		return null;
	}
504955
protected function getUrlAndDecodeResponse($url, PageIndexerResponse $response)
    {
        $headers = $this->getHeaders();
        $rawResponse = $this->getUrl($url, $headers, $this->timeout);
        // convert JSON response to response object properties
        $decodedResponse = $response->getResultsFromJson($rawResponse->getBody()->getContents());

        if ($rawResponse === false || $decodedResponse === false) {
            $this->logger->log(
                SolrLogManager::ERROR,
                'Failed to execute Page Indexer Request. Request ID: ' . $this->requestId,
                [
                    'request ID' => $this->requestId,
                    'request url' => $url,
                    'request headers' => $headers,
                    'response headers' => $rawResponse->getHeaders(),
                    'raw response body' => $rawResponse->getBody()->getContents()
                ]
            );

            throw new \RuntimeException('Failed to execute Page Indexer Request. See log for details. Request ID: ' . $this->requestId, 1319116885);
        }
        return $decodedResponse;
    }