You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Lionel Debroux <li...@yahoo.fr> on 2011/10/27 11:15:24 UTC

bundlerepository and encoded JARs...

Hello,

I recently had trouble installing bundles through the OBR: the JAR
handling code would spit errors about not being able to open the ZIP
file.
With Wireshark, I tracked the problem down to the JAR file having been
gzipped, but not having been uncompressed on the computer side.

Even if they're not explicitly asked for it (which is the case when
downloading a bundle through the OBR), servers are allowed by the
HTTP/1.1 spec to return encoded content:
"If no Accept-Encoding field is present in a request, the server MAY
assume that the client will accept any content coding."
( http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3 )

I worked around the problem the following way:

Index: bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/FileUtil.java
===================================================================
--- bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/FileUtil.java    (révision 1189686)
+++ bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/FileUtil.java    (copie de travail)
@@ -204,6 +204,14 @@
         // Do it the manual way to have a chance to
         // set request properties as proxy auth (EW).
         setProxyAuth(conn);
+
+        // Force identity encoding
+        if ("http".equals(conn.getURL().getProtocol())
+            || "https".equals(conn.getURL().getProtocol()))
+        {
+            conn.setRequestProperty("Accept-Encoding", "");
+        }
+
         try
         {
             return conn.getInputStream();


In the beginning, I also added "conn.setUseCaches(false);" to
purge the local caching proxy's cache, but that was a transient
workaround for gzipped bundles having been cached, which
is no longer necessary after non-encoded bundles have
replaced them in the cache.



Regards,
Lionel.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: bundlerepository and encoded JARs...

Posted by "Richard S. Hall" <he...@ungoverned.org>.
Lionel,

Perhaps you could open an issue [1] against OBR and submit this patch. 
Thanks.

-> richard

[1] https://issues.apache.org/jira/browse/FELIX

On 10/27/11 05:15 , Lionel Debroux wrote:
> Hello,
>
> I recently had trouble installing bundles through the OBR: the JAR
> handling code would spit errors about not being able to open the ZIP
> file.
> With Wireshark, I tracked the problem down to the JAR file having been
> gzipped, but not having been uncompressed on the computer side.
>
> Even if they're not explicitly asked for it (which is the case when
> downloading a bundle through the OBR), servers are allowed by the
> HTTP/1.1 spec to return encoded content:
> "If no Accept-Encoding field is present in a request, the server MAY
> assume that the client will accept any content coding."
> ( http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3 )
>
> I worked around the problem the following way:
>
> Index: bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/FileUtil.java
> ===================================================================
> --- bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/FileUtil.java    (révision 1189686)
> +++ bundlerepository/src/main/java/org/apache/felix/bundlerepository/impl/FileUtil.java    (copie de travail)
> @@ -204,6 +204,14 @@
>           // Do it the manual way to have a chance to
>           // set request properties as proxy auth (EW).
>           setProxyAuth(conn);
> +
> +        // Force identity encoding
> +        if ("http".equals(conn.getURL().getProtocol())
> +            || "https".equals(conn.getURL().getProtocol()))
> +        {
> +            conn.setRequestProperty("Accept-Encoding", "");
> +        }
> +
>           try
>           {
>               return conn.getInputStream();
>
>
> In the beginning, I also added "conn.setUseCaches(false);" to
> purge the local caching proxy's cache, but that was a transient
> workaround for gzipped bundles having been cached, which
> is no longer necessary after non-encoded bundles have
> replaced them in the cache.
>
>
>
> Regards,
> Lionel.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org