/** * Returns an input stream representing all the content that was returned from the server. * * @return an input stream representing all the content that was returned from the server * @exception IOException if an IO error occurs */ public InputStream getInputStream() throws IOException { return webResponse_.getContentAsStream(); }
/** * Returns an input stream representing all the content that was returned from the server. * * @return an input stream representing all the content that was returned from the server * @exception IOException if an IO error occurs */ public InputStream getInputStream() throws IOException { return webResponse_.getContentAsStream(); }
/** * {@inheritDoc} * The default behavior of this method is to return getContentAsStream() on the wrapped webResponse object. */ @Override public InputStream getContentAsStream() throws IOException { return wrappedWebResponse_.getContentAsStream(); }
/** * {@inheritDoc} * The default behavior of this method is to return getContentAsStream() on the wrapped connection object. */ public InputStream getContentAsStream() throws IOException { return wrappedWebResponse_.getContentAsStream(); }
@Override public InputStream getContentAsStream() throws IOException { return delegate.getContentAsStream(); }
/** * Returns an input stream representing all the content that was returned from the server. * * @return an input stream representing all the content that was returned from the server * @exception IOException if an IO error occurs */ public InputStream getInputStream() throws IOException { return webResponse_.getContentAsStream(); }
/** * {@inheritDoc} * The default behavior of this method is to return getContentAsStream() on the wrapped webResponse object. */ @Override public InputStream getContentAsStream() throws IOException { return wrappedWebResponse_.getContentAsStream(); }
/** * {@inheritDoc} * The default behavior of this method is to return getContentAsStream() on the wrapped connection object. */ public InputStream getContentAsStream() throws IOException { return wrappedWebResponse_.getContentAsStream(); }
/** * {@inheritDoc} * The default behavior of this method is to return getContentAsStream() on the wrapped connection object. */ public InputStream getContentAsStream() throws IOException { return wrappedWebResponse_.getContentAsStream(); }
/** * Returns an input stream representing all the content that was returned from the server. * * @return an input stream representing all the content that was returned from the server * @throws IOException in case of IO problems */ public InputStream getInputStream() throws IOException { return getWebResponse().getContentAsStream(); } }
/** * Returns an input stream representing all the content that was returned from the server. * * @return an input stream representing all the content that was returned from the server * @throws IOException in case of IO problems */ public InputStream getInputStream() throws IOException { return getWebResponse().getContentAsStream(); } }
private void readImageIfNeeded() throws IOException { downloadImageIfNeeded(); if (imageReader_ == null) { final ImageInputStream iis = ImageIO.createImageInputStream(imageWebResponse_.getContentAsStream()); final Iterator<ImageReader> iter = ImageIO.getImageReaders(iis); if (!iter.hasNext()) { throw new IOException("No image detected in response"); } imageReader_ = iter.next(); imageReader_.setInput(iis); } }
private void readImageIfNeeded() throws IOException { downloadImageIfNeeded(); if (imageReader_ == null) { final ImageInputStream iis = ImageIO.createImageInputStream(imageWebResponse_.getContentAsStream()); final Iterator<ImageReader> iter = ImageIO.getImageReaders(iis); if (!iter.hasNext()) { throw new IOException("No image detected in response"); } imageReader_ = iter.next(); imageReader_.setInput(iis); } }
private void readImageIfNeeded() throws IOException { downloadImageIfNeeded(); if (imageReader_ == null) { final ImageInputStream iis = ImageIO.createImageInputStream(imageWebResponse_.getContentAsStream()); final Iterator<ImageReader> iter = ImageIO.getImageReaders(iis); if (!iter.hasNext()) { throw new IOException("No image detected in response"); } imageReader_ = iter.next(); imageReader_.setInput(iis); } }
/** * Returns the content charset specified explicitly in the header or in the content, * or {@code null} if none was specified. * @return the content charset specified explicitly in the header or in the content, * or {@code null} if none was specified */ public Charset getContentCharsetOrNull() { try (InputStream is = getContentAsStream()) { return EncodingSniffer.sniffEncoding(getResponseHeaders(), is); } catch (final IOException e) { LOG.warn("Error trying to sniff encoding.", e); return null; } }
/** * Adds the class defined by the WebResponse to the classpath for the applet. * @param className the name of the class to load * @param webResponse the web response * @throws IOException in case of problem working with the response content */ public void addClassToClassPath(final String className, final WebResponse webResponse) throws IOException { try (InputStream content = webResponse.getContentAsStream()) { final byte[] bytes = IOUtils.toByteArray(content); defineClass(className, bytes, 0, bytes.length); } info_.append(" Class: " + webResponse.getWebRequest().getUrl() + "\n"); }
@Override public InputStream getInputStream() { try { return wc.getCurrentWindow().getEnclosedPage().getWebResponse() .getContentAsStream(); } catch (IOException e) { throw new RuntimeException(e); } }
protected Map<String, DomAttr> getAttributesFor(final HtmlImage image) throws IOException { final Map<String, DomAttr> map = createAttributesCopyWithClonedAttribute(image, "src"); final DomAttr srcAttr = map.get("src"); if (srcAttr != null && StringUtils.isNotBlank(srcAttr.getValue())) { final WebResponse response = image.getWebResponse(true); final File file = createFile(srcAttr.getValue(), "." + getSuffix(response)); try (InputStream inputStream = response.getContentAsStream()) { FileUtils.copyInputStreamToFile(inputStream, file); } final String valueOnFileSystem = outputDir_.getName() + FILE_SEPARATOR + file.getName(); srcAttr.setValue(valueOnFileSystem); // this is the clone attribute node, not the original one of the page } return map; }
protected Map<String, DomAttr> getAttributesFor(final HtmlImage image) throws IOException { final Map<String, DomAttr> map = createAttributesCopyWithClonedAttribute(image, DomElement.SRC_ATTRIBUTE); final DomAttr srcAttr = map.get(DomElement.SRC_ATTRIBUTE); if (srcAttr != null && StringUtils.isNotBlank(srcAttr.getValue())) { final WebResponse response = image.getWebResponse(true); final File file = createFile(srcAttr.getValue(), "." + getSuffix(response)); try (InputStream inputStream = response.getContentAsStream()) { FileUtils.copyInputStreamToFile(inputStream, file); } final String valueOnFileSystem = outputDir_.getName() + FILE_SEPARATOR + file.getName(); srcAttr.setValue(valueOnFileSystem); // this is the clone attribute node, not the original one of the page } return map; }
public static JsonObject getPageAsJSONObject(String path, URL url, WebClient client) throws IOException { if (client == null) { client = new WebClient(); } JsonReader jsonReader = Json.createReader(client.getPage(url.toString().concat(path)).getWebResponse().getContentAsStream()); return jsonReader.readObject(); }