Skip to content

Commit 794af04

Browse files
committed
fine tune tests introduced together with brotli support - #13
1 parent 7f484f3 commit 794af04

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/test/java/website/magyar/mitm/proxy/help/AbstractComplexProxyTool.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.slf4j.Logger;
2121
import org.slf4j.LoggerFactory;
2222

23-
import java.lang.reflect.Field;
2423
import java.nio.charset.Charset;
2524
import java.util.concurrent.atomic.AtomicInteger;
2625

@@ -192,21 +191,22 @@ protected ResponseInfo httpPostWithApacheClient(HttpHost host, String resourceUr
192191
request.setEntity(entity);
193192

194193
final HttpResponse response = httpClient.execute(host, request);
194+
Thread.sleep(GRACE_PERIOD);
195195
HttpEntity resEntity = response.getEntity();
196196
Header contentEncodingHeader = resEntity.getContentEncoding();
197197

198198
if (contentEncodingHeader != null) {
199199
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")) {
202202
resEntity = new GzipDecompressingEntity(resEntity);
203203
break;
204204
}
205-
if (encodings[i].getName().equalsIgnoreCase("deflate")) {
205+
if (encoding.getName().equalsIgnoreCase("deflate")) {
206206
resEntity = new DeflateDecompressingEntity(resEntity);
207207
break;
208208
}
209-
if (encodings[i].getName().equalsIgnoreCase("br")) {
209+
if (encoding.getName().equalsIgnoreCase("br")) {
210210
resEntity = new BrotliDecompressingEntity(resEntity);
211211
break;
212212
}
@@ -243,21 +243,22 @@ protected ResponseInfo httpGetWithApacheClient(HttpHost host, String resourceUrl
243243
}
244244

245245
HttpEntity resEntity = response.getEntity();
246+
Thread.sleep(GRACE_PERIOD);
246247

247248
Header contentEncodingHeader = resEntity.getContentEncoding();
248249

249250
if (contentEncodingHeader != null) {
250251
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")) {
253254
resEntity = new GzipDecompressingEntity(resEntity);
254255
break;
255256
}
256-
if (encodings[i].getName().equalsIgnoreCase("deflate")) {
257+
if (encoding.getName().equalsIgnoreCase("deflate")) {
257258
resEntity = new DeflateDecompressingEntity(resEntity);
258259
break;
259260
}
260-
if (encodings[i].getName().equalsIgnoreCase("br")) {
261+
if (encoding.getName().equalsIgnoreCase("br")) {
261262
resEntity = new BrotliDecompressingEntity(resEntity);
262263
break;
263264
}

0 commit comments

Comments
 (0)