﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
12220	[Patch draft] Specify Content-Encoding for HTTP connections	simon04	simon04	"Currently, only the `OsmServerReader` specifies the HTTP request header `Accept-Encoding: gzip, deflate` to fetch the response in a compressed form (given the server supports it).

As a first improvement, `Utils#openURLAndDecompress` could also send this header and uncompress the returned `InputStream`:
{{{#!patch
diff --git a/src/org/openstreetmap/josm/tools/Utils.java b/src/org/openstreetmap/josm/tools/Utils.java
index 53d45f5..6d6097d 100644
--- a/src/org/openstreetmap/josm/tools/Utils.java
+++ b/src/org/openstreetmap/josm/tools/Utils.java
@@ -54,6 +54,8 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.zip.GZIPInputStream;
+import java.util.zip.Inflater;
+import java.util.zip.InflaterInputStream;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 import java.util.zip.ZipInputStream;
@@ -800,6 +802,7 @@ public static InputStream openURL(URL url) throws IOException {
      */
     public static InputStream openURLAndDecompress(final URL url, final boolean decompress) throws IOException {
         final URLConnection connection = setupURLConnection(url.openConnection());
+        connection.setRequestProperty(""Accept-Encoding"", ""gzip, deflate"");
         final InputStream in = connection.getInputStream();
         if (decompress) {
             switch (connection.getHeaderField(""Content-Type"")) {
@@ -811,6 +814,12 @@ public static InputStream openURLAndDecompress(final URL url, final boolean deco
                 return getBZip2InputStream(in);
             }
         }
+        switch (connection.getContentEncoding()) {
+        case ""gzip"":
+            return getGZipInputStream(in);
+        case ""deflate"":
+            return new InflaterInputStream(in, new Inflater(true));
+        }
         return in;
     }
 
}}}

In a next step, the 17 usages of `Utils#openHttpConnection` could be adapted one-by-one to also make use of HTTP compression."	enhancement	closed	normal		Core		wontfix	http compression urlconnection	
