private String requestRaw(String path) throws IOException { HttpRequest getRequest = TRANSPORT.createRequestFactory().buildGetRequest( new GenericUrl(baseUrl + path)); HttpHeaders headers = new HttpHeaders(); headers.setAuthorization("Bearer " + accessToken); getRequest.setHeaders(headers); HttpResponse response = getRequest.execute(); validateResponse(getRequest, response, 200); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); IOUtils.copy(response.getContent(), byteArrayOutputStream, true); return byteArrayOutputStream.toString(); }
LowLevelHttpResponse lowLevelHttpResponse = (LowLevelHttpResponse) responseField.get(httpResponse); IOUtils.copy(lowLevelHttpResponse.getContent(), output); } catch (IllegalAccessException | NoSuchFieldException ex) { throw new StorageException(
@Override protected String doGetContent() throws IOException { try (InputStream is = response.getContent(); ByteArrayOutputStream bos = new ByteArrayOutputStream()) { copy(is, bos); return new String(bos.toByteArray(), response.getContentCharset()); } } }
@Override public void handlePdf(File pdfFile) { try { if (pdfFile != null) { headers.put("Content-disposition", "attachment; filename=\"" + args.get("name") +"\""); brh.setContentType("application/pdf", headers); FileInputStream is = new FileInputStream(pdfFile); IOUtils.copy(is, brh.getOutputStream(), true); } else { brh.setContentType("text/plain", headers); brh.getOutputStream().write("Oups! Failed to export pdf!".getBytes()); } } catch (IOException e) { logger.warn("Failed! {}", args, e); } } });
IOUtils.copy(inputStream, outStream);
IOUtils.copy(response.getContent(), outputStream); } finally { response.disconnect();
try { ByteArrayOutputStream out = new ByteArrayOutputStream(); IOUtils.copy(content, out); responseContent = out.toString(contentCharset.name()); } catch (IOException e) {
try { ByteArrayOutputStream out = new ByteArrayOutputStream(); IOUtils.copy(content, out, false); responseContent = out.toString(contentCharset.name()); } catch (IOException e) {
try { ByteArrayOutputStream out = new ByteArrayOutputStream(); IOUtils.copy(content, out, false); responseContent = out.toString(contentCharset.name()); } catch (IOException e) {
LowLevelHttpResponse lowLevelHttpResponse = (LowLevelHttpResponse) responseField.get(httpResponse); IOUtils.copy(lowLevelHttpResponse.getContent(), output); } catch (IllegalAccessException | NoSuchFieldException ex) { throw new StorageException(