Skip to content

Commit

Permalink
Merge pull request #71 from laeubi/dont_use_field_for_content_compres…
Browse files Browse the repository at this point in the history
…sion

Use local variable instead of a field for contentCompressionEnabled
  • Loading branch information
scottslewis authored Oct 21, 2023
2 parents dbacc2a + 2fa9516 commit 3b874a3
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,6 @@ public class HttpClientRetrieveFileTransfer extends AbstractRetrieveFileTransfer

private FileTransferJob connectJob;

private boolean contentCompressionEnabled;

private HttpRequest httpRequest;

public HttpClientRetrieveFileTransfer(HttpClient client) {
Expand Down Expand Up @@ -547,14 +545,17 @@ protected void openStreams() throws IncomingFileTransferException {
// Set request header for possible gzip encoding, but only if
// 1) The file range specification is null (we want the whole file)
// 2) The target remote file does *not* end in .gz (see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=280205)
boolean contentCompressionEnabled;
if (getFileRangeSpecification() == null && !targetHasGzSuffix(super.getRemoteFileName())) {
// The interceptors to provide gzip are always added and are enabled by default
Trace.trace(Activator.PLUGIN_ID, "Accept-Encoding: gzip,deflate added to request header"); //$NON-NLS-1$
setContentCompressionEnabled(rcfgBuilder, true);
contentCompressionEnabled = true;
} else {
// Disable the interceptors to provide gzip
Trace.trace(Activator.PLUGIN_ID, "Accept-Encoding NOT added to header"); //$NON-NLS-1$
setContentCompressionEnabled(rcfgBuilder, false);
contentCompressionEnabled = false;
}
httpRequest = rcfgBuilder.build();

Expand Down Expand Up @@ -647,7 +648,6 @@ private void consume(CompletableFuture<HttpResponse<InputStream>> httpResponse)
}

private void setContentCompressionEnabled(Builder builder, boolean value) {
this.contentCompressionEnabled = value;
if (value) {
builder.setHeader(ACCEPT_ENCODING_HEADER, GZIP_ENCODING);
} else {
Expand Down

0 comments on commit 3b874a3

Please sign in to comment.