@@ -132,6 +132,7 @@ private CompletableFuture<Resource> downloadFrom(final URL url) {
132132 }
133133
134134 private Resource tryDownloading (final URL downloadFrom ) throws IOException {
135+ ensureRequestInterval ();
135136 DownloadDetails downloadDetails = null ;
136137 try (final CloseableConnection connection = getDownloadConnection (downloadFrom )) {
137138 downloadDetails = getDownloadDetails (connection );
@@ -158,23 +159,33 @@ private Resource tryDownloading(final URL downloadFrom) throws IOException {
158159 }
159160 }
160161
162+ private void ensureRequestInterval () {
163+ final int httpsRequestInterval = getTimeValue (ConfigurationConstants .KEY_HTTPCONNECTION_REQUEST_INTERVAL );
164+ if (httpsRequestInterval > 0 ) {
165+ try {
166+ Thread .sleep (httpsRequestInterval );
167+ } catch (InterruptedException ignored ) {
168+ }
169+ }
170+ }
171+
161172 private CloseableConnection getDownloadConnection (final URL location ) throws IOException {
162173 final Map <String , String > requestProperties = new HashMap <>();
163174 requestProperties .put (ACCEPT_ENCODING_HEADER , PACK_200_OR_GZIP );
164- return ConnectionFactory .openConnection (location , HttpMethod .GET , requestProperties , getTimeoutValue (ConfigurationConstants .KEY_HTTPCONNECTION_CONNECT_TIMEOUT ), getTimeoutValue (ConfigurationConstants .KEY_HTTPCONNECTION_READ_TIMEOUT ));
175+ return ConnectionFactory .openConnection (location , HttpMethod .GET , requestProperties , getTimeValue (ConfigurationConstants .KEY_HTTPCONNECTION_CONNECT_TIMEOUT ), getTimeValue (ConfigurationConstants .KEY_HTTPCONNECTION_READ_TIMEOUT ));
165176 }
166177
167- private int getTimeoutValue (final String key ) {
168- int timeout = 0 ;
178+ private int getTimeValue (final String key ) {
179+ int timeValue = 0 ;
169180 final String value = JNLPRuntime .getConfiguration ().getProperty (key );
170181 if (value != null && value .trim ().length () != 0 ) {
171182 try {
172- timeout = Integer .valueOf (value );
183+ timeValue = Integer .valueOf (value );
173184 } catch (NumberFormatException e ) {
174185 LOG .error ("Could not parse {} with value '{}' - reason {}" , key , value , e .getMessage ());
175186 }
176187 }
177- return timeout ;
188+ return timeValue ;
178189 }
179190
180191 private long tryDownloading (final DownloadDetails downloadDetails ) throws IOException {
0 commit comments