question: public boolean postData ( InputStream data , Long length , OutputStream output , String type , URL url ) { if ( mockMode ) return true ; boolean success = true ; if ( type == null ) type = DEFAULT_CONTENT_TYPE ; HttpURLConnection urlc = null ; try { try { urlc = ( HttpURLConnection ) url . openConnection ( ) ; try { urlc . setRequestMethod ( "POST" ) ; } catch ( ProtocolException e ) { fatal ( "Shouldn't happen: HttpURLConnection doesn't support POST??" + e ) ; } urlc . setDoOutput ( true ) ; urlc . setDoInput ( true ) ; urlc . setUseCaches ( false ) ; urlc . setAllowUserInteraction ( false ) ; urlc . setRequestProperty ( "Content-type" , type ) ; basicAuth ( urlc ) ; if ( null != length ) { urlc . setFixedLengthStreamingMode ( length ) ; } else { urlc . setChunkedStreamingMode ( - 1 ) ; } urlc . connect ( ) ; } catch ( IOException e ) { fatal ( "Connection error (is Solr running at " + solrUrl + " ?): " + e ) ; success = false ; } catch ( Exception e ) { fatal ( "POST failed with error " + e . getMessage ( ) ) ; } try ( final OutputStream out = urlc . getOutputStream ( ) ) { pipe ( data , out ) ; } catch ( IOException e ) { fatal ( "IOException while posting data: " + e ) ; } try { success &= checkResponseCode ( urlc ) ; try ( final InputStream in = urlc . getInputStream ( ) ) { pipe ( in , output ) ; } } catch ( IOException e ) { warn ( "IOException while reading response: " + e ) ; success = false ; } catch ( GeneralSecurityException e ) { fatal ( "Looks like Solr is secured and would not let us in. Try with another user in '-u' parameter" ) ; } } finally { if ( urlc != null ) urlc . disconnect ( ) ; } return success ; }
target:  Reads data from the data stream and posts it to solr, writes to the response to output