private Record parseResponse ( InputStream response ) throws StageException { Record record = null ; if ( conf . httpMethod == HttpMethod . HEAD ) { // Head will have no body so can't be parsed. Return an empty record. record = getContext ( ) . createRecord ( "" ) ; record . set ( Field . create ( new HashMap ( ) ) ) ; } else if ( response != null ) { try ( DataParser parser = parserFactory . getParser ( "" , response , "0" ) ) { // A response may only contain a single record, so we only parse it once. record = parser . parse ( ) ; if ( conf . dataFormat == DataFormat . TEXT ) { // Output is placed in a field "/text" so we remove it here. record . set ( record . get ( "/text" ) ) ; } } catch ( IOException | DataParserException e ) { errorRecordHandler . onError ( Errors . HTTP_00 , e . toString ( ) , e ) ; } } return record ; }
Parses the HTTP response text from a request into SDC Records