|
20 | 20 | import org.slf4j.Logger; |
21 | 21 | import org.slf4j.LoggerFactory; |
22 | 22 |
|
23 | | -import java.lang.reflect.Field; |
24 | 23 | import java.nio.charset.Charset; |
25 | 24 | import java.util.concurrent.atomic.AtomicInteger; |
26 | 25 |
|
@@ -192,21 +191,22 @@ protected ResponseInfo httpPostWithApacheClient(HttpHost host, String resourceUr |
192 | 191 | request.setEntity(entity); |
193 | 192 |
|
194 | 193 | final HttpResponse response = httpClient.execute(host, request); |
| 194 | + Thread.sleep(GRACE_PERIOD); |
195 | 195 | HttpEntity resEntity = response.getEntity(); |
196 | 196 | Header contentEncodingHeader = resEntity.getContentEncoding(); |
197 | 197 |
|
198 | 198 | if (contentEncodingHeader != null) { |
199 | 199 | HeaderElement[] encodings = contentEncodingHeader.getElements(); |
200 | | - for (int i = 0; i < encodings.length; i++) { |
201 | | - if (encodings[i].getName().equalsIgnoreCase("gzip")) { |
| 200 | + for (HeaderElement encoding : encodings) { |
| 201 | + if (encoding.getName().equalsIgnoreCase("gzip")) { |
202 | 202 | resEntity = new GzipDecompressingEntity(resEntity); |
203 | 203 | break; |
204 | 204 | } |
205 | | - if (encodings[i].getName().equalsIgnoreCase("deflate")) { |
| 205 | + if (encoding.getName().equalsIgnoreCase("deflate")) { |
206 | 206 | resEntity = new DeflateDecompressingEntity(resEntity); |
207 | 207 | break; |
208 | 208 | } |
209 | | - if (encodings[i].getName().equalsIgnoreCase("br")) { |
| 209 | + if (encoding.getName().equalsIgnoreCase("br")) { |
210 | 210 | resEntity = new BrotliDecompressingEntity(resEntity); |
211 | 211 | break; |
212 | 212 | } |
@@ -243,21 +243,22 @@ protected ResponseInfo httpGetWithApacheClient(HttpHost host, String resourceUrl |
243 | 243 | } |
244 | 244 |
|
245 | 245 | HttpEntity resEntity = response.getEntity(); |
| 246 | + Thread.sleep(GRACE_PERIOD); |
246 | 247 |
|
247 | 248 | Header contentEncodingHeader = resEntity.getContentEncoding(); |
248 | 249 |
|
249 | 250 | if (contentEncodingHeader != null) { |
250 | 251 | HeaderElement[] encodings = contentEncodingHeader.getElements(); |
251 | | - for (int i = 0; i < encodings.length; i++) { |
252 | | - if (encodings[i].getName().equalsIgnoreCase("gzip")) { |
| 252 | + for (HeaderElement encoding : encodings) { |
| 253 | + if (encoding.getName().equalsIgnoreCase("gzip")) { |
253 | 254 | resEntity = new GzipDecompressingEntity(resEntity); |
254 | 255 | break; |
255 | 256 | } |
256 | | - if (encodings[i].getName().equalsIgnoreCase("deflate")) { |
| 257 | + if (encoding.getName().equalsIgnoreCase("deflate")) { |
257 | 258 | resEntity = new DeflateDecompressingEntity(resEntity); |
258 | 259 | break; |
259 | 260 | } |
260 | | - if (encodings[i].getName().equalsIgnoreCase("br")) { |
| 261 | + if (encoding.getName().equalsIgnoreCase("br")) { |
261 | 262 | resEntity = new BrotliDecompressingEntity(resEntity); |
262 | 263 | break; |
263 | 264 | } |
|
0 commit comments