public String getRequest ( final URL url ) throws MovieDbException { try { HttpGet httpGet = new HttpGet ( url . toURI ( ) ) ; httpGet . addHeader ( HttpHeaders . ACCEPT , APPLICATION_JSON ) ; DigestedResponse response = DigestedResponseReader . requestContent ( httpClient , httpGet , CHARSET ) ; long retryCount = 0L ; // If we have a 429 response, wait and try again while ( response . getStatusCode ( ) == STATUS_TOO_MANY_REQUESTS && retryCount ++ <= RETRY_MAX ) { delay ( retryCount ) ; // Retry the request response = DigestedResponseReader . requestContent ( httpClient , httpGet , CHARSET ) ; } return validateResponse ( response , url ) ; } catch ( URISyntaxException | IOException ex ) { throw new MovieDbException ( ApiExceptionType . CONNECTION_ERROR , null , url , ex ) ; } catch ( RuntimeException ex ) { throw new MovieDbException ( ApiExceptionType . HTTP_503_ERROR , "Service Unavailable" , url , ex ) ; } }
GET data from the URL