protected String performGetRequest ( String requestString ) throws IOException { HttpGet request = new HttpGet ( getBaseUrl ( ) + requestString ) ; if ( USER != null && ! USER . isEmpty ( ) ) { request . setHeader ( "Authorization" , USER + ":" + TOKEN ) ; } String json = null ; CloseableHttpClient httpClient = HttpClients . createDefault ( ) ; try { logger . debug ( "------------------------------------------------" ) ; logger . debug ( "OSS Index GET: " + getBaseUrl ( ) + requestString ) ; logger . debug ( "------------------------------------------------" ) ; CloseableHttpResponse response = httpClient . execute ( request ) ; int code = response . getStatusLine ( ) . getStatusCode ( ) ; if ( code < 200 || code > 299 ) { throw new ConnectException ( response . getStatusLine ( ) . getReasonPhrase ( ) + " (" + code + ")" ) ; } json = EntityUtils . toString ( response . getEntity ( ) , "UTF-8" ) ; } catch ( ParseException e ) { throw new IOException ( e ) ; } finally { httpClient . close ( ) ; } return json ; }
Perform a get request