/** * Retrieves a {@link Reader} for the response body content (if there is any). The content may have already been processed. * * @return a {@link Reader} for the response body content (may be empty) */ default Reader getReader() { return new BufferedReader(new InputStreamReader(getInputStream())); } }
/** * Retrieves a {@link Reader} for the response body content (if there is any). The content may have already been processed. * * @return a {@link Reader} for the response body content (may be empty) */ default Reader getReader() { return new BufferedReader(new InputStreamReader(getInputStream())); } }
/** * Retrieves a {@link Reader} for the response body content (if there is any). * * @return a {@link Reader} for the response body content (may be empty) */ default Reader getReader() { return new BufferedReader(new InputStreamReader(getInputStream())); } }
/** * Standard parser for raw bytes. * * @param fromServer Backend indenpendent representation of data returned from http server * @return Raw bytes of body returned from http server */ public static byte[] streamToBytes(final ChainedHttpConfig config, final FromServer fromServer) { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); transfer(fromServer.getInputStream(), baos, true); return baos.toByteArray(); }
/** * Standard parser for raw bytes. * * @param fromServer Backend indenpendent representation of data returned from http server * @return Raw bytes of body returned from http server */ public static byte[] streamToBytes(final ChainedHttpConfig config, final FromServer fromServer) { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); IoUtils.transfer(fromServer.getInputStream(), baos, true); return baos.toByteArray(); }
/** * Standard parser for raw bytes. * * @param fromServer Backend indenpendent representation of data returned from http server * @return Raw bytes of body returned from http server */ public static byte[] streamToBytes(final ChainedHttpConfig config, final FromServer fromServer) { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); IoUtils.transfer(fromServer.getInputStream(), baos, true); return baos.toByteArray(); }
/** * Method that provides an HTML parser for response configuration (uses JSoup). * * @param config the chained configuration * @param fromServer the server response adapter * @return the parsed HTML content (a {@link Document} object) */ public static Object jsoupParse(final ChainedHttpConfig config, final FromServer fromServer) { try { return Jsoup.parse(fromServer.getInputStream(), fromServer.getCharset().name(), fromServer.getUri().toString()); } catch (IOException e) { throw new RuntimeException(e); } }
/** * Standard parser for responses with content type 'application/x-www-form-urlencoded'. * * @param fromServer Backend indenpendent representation of data returned from http server * @return Form data */ public static Map<String, List<String>> form(final ChainedHttpConfig config, final FromServer fromServer) { return Form.decode(fromServer.getInputStream(), fromServer.getCharset()); }
private static File fileParser(final ChainedHttpConfig config, final FromServer fs) { try { final File file = (File) config.actualContext(fs.getContentType(), ID); transfer(fs.getInputStream(), new FileOutputStream(file), true); return file; } catch (IOException e) { throw new RuntimeException(e); } }
/** * Standard parser for responses with content type 'application/x-www-form-urlencoded'. * * @param fromServer Backend indenpendent representation of data returned from http server * @return Form data */ public static Map<String, List<String>> form(final ChainedHttpConfig config, final FromServer fromServer) { return Form.decode(fromServer.getInputStream(), fromServer.getCharset()); }
/** * Standard parser for responses with content type 'application/x-www-form-urlencoded'. * * @param fromServer Backend indenpendent representation of data returned from http server * @return Form data */ public static Map<String, List<String>> form(final ChainedHttpConfig config, final FromServer fromServer) { return Form.decode(fromServer.getInputStream(), fromServer.getCharset()); }
/** * Standard parser for json responses. * * @param fromServer Backend indenpendent representation of data returned from http server * @return Body of response */ public static Object json(final ChainedHttpConfig config, final FromServer fromServer) { return new JsonSlurper().parse(new InputStreamReader(fromServer.getInputStream(), fromServer.getCharset())); }
/** * Standard parser for json responses. * * @param fromServer Backend indenpendent representation of data returned from http server * @return Body of response */ public static Object json(final ChainedHttpConfig config, final FromServer fromServer) { return new JsonSlurper().parse(new InputStreamReader(fromServer.getInputStream(), fromServer.getCharset())); } }
/** * Method that provides an HTML parser for response configuration (uses necko parser). * * @param config the chained configuration * @param fromServer the server response adapter * @return the parsed HTML content (a {@link groovy.util.slurpersupport.GPathResult} object) */ public static Object neckoParse(final ChainedHttpConfig config, final FromServer fromServer) { try { final XMLReader p = new org.cyberneko.html.parsers.SAXParser(); p.setEntityResolver(NativeHandlers.Parsers.catalogResolver); return new XmlSlurper(p).parse(new InputStreamReader(fromServer.getInputStream(), fromServer.getCharset())); } catch (IOException | SAXException ex) { throw new RuntimeException(ex); } }
/** * Standard parser for json responses. * * @param fromServer Backend indenpendent representation of data returned from http server * @return Body of response */ public static Object json(final ChainedHttpConfig config, final FromServer fromServer) { return new JsonSlurper().parse(new InputStreamReader(fromServer.getInputStream(), fromServer.getCharset())); }
private static File fileParser(final ChainedHttpConfig config, final FromServer fs) { try { final File file = (File) config.actualContext(fs.getContentType(), ID); transfer(fs.getInputStream(), new FileOutputStream(file), true); return file; } catch (IOException e) { throw new TransportingException(e); } }
private static OutputStream streamParser(final ChainedHttpConfig config, final FromServer fs) { final OutputStream ostream = (OutputStream) config.actualContext(fs.getContentType(), ID); transfer(fs.getInputStream(), ostream, false); return ostream; } }
private static File fileParser(final ChainedHttpConfig config, final FromServer fs) { try { final File file = (File) config.actualContext(fs.getContentType(), ID); transfer(fs.getInputStream(), new FileOutputStream(file), true); return file; } catch (IOException e) { throw new TransportingException(e); } }
private static OutputStream streamParser(final ChainedHttpConfig config, final FromServer fs) { final OutputStream ostream = (OutputStream) config.actualContext(fs.getContentType(), ID); transfer(fs.getInputStream(), ostream, false); return ostream; } }
private static OutputStream streamParser(final ChainedHttpConfig config, final FromServer fs) { final OutputStream ostream = (OutputStream) config.actualContext(fs.getContentType(), ID); transfer(fs.getInputStream(), ostream, false); return ostream; } }