/** * 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()); }
/** * Standard parser for text response content. * * @param config the http client configuration * @param fromServer Backend independent representation of data returned from http server * @return Body of response */ public static String textToString(final ChainedHttpConfig config, final FromServer fromServer) { try { final Reader reader = new InputStreamReader(fromServer.getInputStream(), fromServer.getCharset()); final Expanding e = tlExpanding.get(); e.charBuffer.clear(); int total; while ((total = reader.read(e.charAry)) != -1) { e.append(total); } e.charBuffer.flip(); return e.charBuffer.toString(); } catch (IOException ioe) { throw new RuntimeException(ioe); } }
/** * 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 TransportingException(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()); }
/** * 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 TransportingException(e); } }
/** * 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 text response content. * * @param config the http client configuration * @param fromServer Backend independent representation of data returned from http server * @return Body of response */ public static String textToString(final ChainedHttpConfig config, final FromServer fromServer) { try { final Reader reader = new InputStreamReader(fromServer.getInputStream(), fromServer.getCharset()); final Expanding e = tlExpanding.get(); e.charBuffer.clear(); int total; while ((total = reader.read(e.charAry)) != -1) { e.append(total); } e.charBuffer.flip(); return e.charBuffer.toString(); } catch (IOException ioe) { throw new TransportingException(ioe); } }
/** * Standard parser for text response content. * * @param config the http client configuration * @param fromServer Backend independent representation of data returned from http server * @return Body of response */ public static String textToString(final ChainedHttpConfig config, final FromServer fromServer) { try { final Reader reader = new InputStreamReader(fromServer.getInputStream(), fromServer.getCharset()); final Expanding e = tlExpanding.get(); e.charBuffer.clear(); int total; while ((total = reader.read(e.charAry)) != -1) { e.append(total); } e.charBuffer.flip(); return e.charBuffer.toString(); } catch (IOException ioe) { throw new TransportingException(ioe); } }
/** * 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); } }
/** * 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 TransportingException(ex); } }
/** * 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 TransportingException(ex); } }
/** * Standard parser for xml responses. * * @param fromServer Backend indenpendent representation of data returned from http server * @return Body of response */ public static GPathResult xml(final ChainedHttpConfig config, final FromServer fromServer) { try { final XmlSlurper xml = new XmlSlurper(); xml.setEntityResolver(catalogResolver); xml.setFeature("http://apache.org/xml/features/disallow-doctype-decl", false); xml.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); return xml.parse(new InputStreamReader(fromServer.getInputStream(), fromServer.getCharset())); } catch (IOException | SAXException | ParserConfigurationException ex) { throw new RuntimeException(ex); } }
/** * Standard parser for xml responses. * * @param fromServer Backend indenpendent representation of data returned from http server * @return Body of response */ public static GPathResult xml(final ChainedHttpConfig config, final FromServer fromServer) { try { final XmlSlurper xml = new XmlSlurper(); xml.setEntityResolver(catalogResolver); xml.setFeature("http://apache.org/xml/features/disallow-doctype-decl", false); xml.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); return xml.parse(new InputStreamReader(fromServer.getInputStream(), fromServer.getCharset())); } catch (IOException | SAXException | ParserConfigurationException ex) { throw new TransportingException(ex); } }
/** * Standard parser for xml responses. * * @param fromServer Backend indenpendent representation of data returned from http server * @return Body of response */ public static GPathResult xml(final ChainedHttpConfig config, final FromServer fromServer) { try { final XmlSlurper xml = new XmlSlurper(); xml.setEntityResolver(catalogResolver); xml.setFeature("http://apache.org/xml/features/disallow-doctype-decl", false); xml.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); return xml.parse(new InputStreamReader(fromServer.getInputStream(), fromServer.getCharset())); } catch (IOException | SAXException | ParserConfigurationException ex) { throw new TransportingException(ex); } }