public CrossDomainRpc loadRpc ( HttpServletRequest request ) throws IOException { Charset encoding ; try { String enc = request . getCharacterEncoding ( ) ; encoding = Charset . forName ( enc ) ; } catch ( IllegalArgumentException | NullPointerException e ) { encoding = UTF_8 ; } // We tend to look at the input stream, rather than the reader. try ( InputStream in = request . getInputStream ( ) ; Reader reader = new InputStreamReader ( in , encoding ) ; JsonInput jsonInput = json . newInput ( reader ) ) { Map < String , Object > read = jsonInput . read ( MAP_TYPE ) ; return new CrossDomainRpc ( getField ( read , Field . METHOD ) , getField ( read , Field . PATH ) , getField ( read , Field . DATA ) ) ; } catch ( JsonException e ) { throw new IllegalArgumentException ( "Failed to parse JSON request: " + e . getMessage ( ) , e ) ; } }
Parses the request for a CrossDomainRpc .