You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by candrews <ca...@integralblue.com> on 2011/11/03 19:32:30 UTC

HttpClient-Cache release that works against HttpClient 4.0?

HttpClient-Cache doesn't work against HttpClient 4.0 because it uses
org.apache.http.util.EntityUtils.consume(org.apache.http.HttpEntity) which
wasn't introduced until HttpClient 4.1.

Since Android uses HttpClient 4.0 (yes, it sucks that they won't upgrade,
and I don't understand their reasons for not upgrading, but anyways), this
means you can't use HttpClient-Cache on Android - and IMHO, it would be
really useful.

Could HttpClient-Cache simply not use
org.apache.http.util.EntityUtils.consume and therefore set the minimum
HttpClient version to 4.0? The change seems quite simple - in
ResponseProtocolCompliance, use this method body instead of the existing
one:

    private void consumeBody(HttpResponse response) throws IOException {
        HttpEntity body = response.getEntity();
        if (body != null){
         if (body.isStreaming()) {
             InputStream instream = body.getContent();
             if (instream != null) {
                 instream.close();
             }
         }
    }

Thank you,
~Craig
-- 
View this message in context: http://old.nabble.com/HttpClient-Cache-release-that-works-against-HttpClient-4.0--tp32775131p32775131.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


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


Re: HttpClient-Cache release that works against HttpClient 4.0?

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2011-11-03 at 11:32 -0700, candrews wrote:
> HttpClient-Cache doesn't work against HttpClient 4.0 because it uses
> org.apache.http.util.EntityUtils.consume(org.apache.http.HttpEntity) which
> wasn't introduced until HttpClient 4.1.
> 
> Since Android uses HttpClient 4.0 (yes, it sucks that they won't upgrade,
> and I don't understand their reasons for not upgrading, but anyways), this
> means you can't use HttpClient-Cache on Android - and IMHO, it would be
> really useful.
> 
> Could HttpClient-Cache simply not use
> org.apache.http.util.EntityUtils.consume and therefore set the minimum
> HttpClient version to 4.0? The change seems quite simple - in
> ResponseProtocolCompliance, use this method body instead of the existing
> one:
> 
>     private void consumeBody(HttpResponse response) throws IOException {
>         HttpEntity body = response.getEntity();
>         if (body != null){
>          if (body.isStreaming()) {
>              InputStream instream = body.getContent();
>              if (instream != null) {
>                  instream.close();
>              }
>          }
>     }
> 
> Thank you,
> ~Craig

Crag,

The problem is that what Google ships with Android platform is an
extremely outdated, pre-BETA version of HttpClient. There have been
literally hundreds of changes and bug fixes since that version that
Google never bothered to backport. I personally see no point in
maintaining compatibility with Adnroid's version of HttpClient.  

You will be much better off using the latest version of HttpClient
repackaged to a different name space such as
'screw.you.google.org.apache.http'. If you are a Maven user you could
use Maven Shade plugin to create a package of HttpClient with a custom
package namespace.  

Hope this helps

Oleg


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


Re: Fully Android compatible HttpClient 4.1.x; was Re: HttpClient-Cache release that works against HttpClient 4.0?

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Sun, 2012-07-08 at 06:39 +0000, Mayur Rustagi wrote:
> Hi Guys,
> Any progress on this? This would work wonders with my application.
> Regards
> Mayur
> 


Not much progress, unfortunately. I have my hands full with the next
release of HttpAsyncClient and a major refactoring of HttpClient in the
4.3 branch. It might well happen that 4.3 release would technically be
the best opportunity for an Android port. Pretty much all high level
impl classes shipped with Android will be deprecated by then and
replaced with new implementations, making it much easier to provide
backward compatibility with previous releases.  

Anyway, help would be welcome.

Oleg


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


Re: Fully Android compatible HttpClient 4.1.x; was Re: HttpClient-Cache release that works against HttpClient 4.0?

Posted by Mayur Rustagi <ma...@scan2cart.com>.
Hi Guys,
Any progress on this? This would work wonders with my application.
Regards
Mayur


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


Re: Fully Android compatible HttpClient 4.1.x; was Re: HttpClient-Cache release that works against HttpClient 4.0?

Posted by Oleg Kalnichevski <ol...@apache.org>.
candrews <ca...@integralblue.com> wrote:

>
>That idea sounds awesome to me - I may even do it. How would you like
>such a
>thing implemented? As a script? A diff against "regular" httpclient?
>

Ideally a script that svn copies files off a release tag, say 4.1.2 and a diff containing adjustments. That would be the ideal case.


>Interestingly, for the case of HttpClient-Cache, my original problem
>would
>not be solved by this approach. HttpClient-Cache uses
>EntityUtils.consume
>statically, and there's no way to fix that. Perhaps a simple change to
>not
>use EntityUtils.consume and thus conform to the HttpClient 4.0 API
>would be
>alright? Also, I confirmed with that change, HttpClient-Cache works in
>Android (the jar, that is) and the compiled jar only uses HttpClient
>4.0
>APIs. The unit tests, however, use methods from beyond the 4.0 API and
>thus
>do not run against HttpClient 4.0.
>

There is absolutely nothing that prevents you from shading that class and making the cache module use that shaded class instead of the old one. Only public interfaces and public classes referenced by those interfaces cannot be shaded.

Oleg


>
>olegk wrote:
>> 
>> On Thu, Nov 10, 2011 at 11:49:09AM -0800, candrews wrote:
>>> 
>>> I thought of that, but it won't work when an Android app has
>dependencies
>>> that use HttpClient.
>>> 
>>> I use Spring Android Rest Template. My goal is to use Rest Template
>with
>>> caching via HttpClient-Cache. If I shade HttpClient (and
>>> HttpClient-Cache),
>>> and include the shaded jar in my project, then Rest Template will
>not use
>>> it
>>> (as it's compiled to use the "real" HttpClient, not my private copy
>in a
>>> new
>>> namespace). So now I have to process Rest Template using Maven
>Shade. I'd
>>> also like osmdroid to use the same HttpClient, so I have to shade it
>>> too...
>>> Now I'm using at least 4 custom created jar's outside of my Android
>app's
>>> ant build system, causing a serious maintenance problem :-)
>>> 
>>> Is there an ant analogue to Maven Shade? Is there a different
>approach to
>>> solving these problems?
>>> 
>> 
>> There is a way to build a reasonably up-to-date version of HttpClient
>> fully compatible with Android: shade impl classes and new interfaces
>only
>> and make them compileable against 4.0 API. That would involve a bit
>more
>> work but result in a library fully compatible with Android and 3rd
>party
>> libraries at the same time.
>> 
>> If someone were to contribute such a port to the project, we probably
>> could even ship it as an official ASF release.
>> 
>> Oleg
>> 
>> 
>> 
>>> (I apologize if I'm hijacking this list inappropriately - IMHO this
>seems
>>> relevant to httpclient-user, and I'm not sure where else to ask.
>I'll
>>> happily shut up if the list maintainer believes this thread is
>>> off-topic).
>>> 
>>> Thanks again!
>>> ~Craig
>>> 
>>> 
>>> sebb-2-2 wrote:
>>> > 
>>> > On 9 November 2011 04:05, candrews <ca...@integralblue.com>
>wrote:
>>> >>
>>> >> Maven Shade isn't compatible with maven-android-plugin:
>>> >>
>https://code.google.com/p/maven-android-plugin/issues/detail?id=170
>>> >> Perhaps
>>> >> when that is resolved, Shade will be a solution for Maven users.
>But
>>> what
>>> >> about Ant users (which I think are what most of the Android apps
>are
>>> >> built
>>> >> with)?
>>> > 
>>> > It would also be possible to use the Maven Shade plugin to create
>a
>>> > version of the HC jars with a different package name.
>>> > This would be done independently of any Android build, whether
>using
>>> > Maven or Ant.
>>> > 
>>> > You then build the Android stuff against the shaded jar, using the
>new
>>> > package names.
>>> > 
>>> > This is not an ideal long-term solution, but should be sufficient
>for
>>> > prototyping purposes.
>>> > 
>>> >
>---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>>> > For additional commands, e-mail:
>httpclient-users-help@hc.apache.org
>>> > 
>>> > 
>>> > 
>>> 
>>> -- 
>>> View this message in context:
>>>
>http://old.nabble.com/HttpClient-Cache-release-that-works-against-HttpClient-4.0--tp32775131p32821369.html
>>> Sent from the HttpClient-User mailing list archive at Nabble.com.
>>> 
>>> 
>>>
>---------------------------------------------------------------------
>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>> 
>> 
>> 
>
>-- 
>View this message in context:
>http://old.nabble.com/HttpClient-Cache-release-that-works-against-HttpClient-4.0--tp32775131p32826896.html
>Sent from the HttpClient-User mailing list archive at Nabble.com.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>For additional commands, e-mail: httpclient-users-help@hc.apache.org



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


Re: Fully Android compatible HttpClient 4.1.x; was Re: HttpClient-Cache release that works against HttpClient 4.0?

Posted by candrews <ca...@integralblue.com>.
That idea sounds awesome to me - I may even do it. How would you like such a
thing implemented? As a script? A diff against "regular" httpclient?

Interestingly, for the case of HttpClient-Cache, my original problem would
not be solved by this approach. HttpClient-Cache uses EntityUtils.consume
statically, and there's no way to fix that. Perhaps a simple change to not
use EntityUtils.consume and thus conform to the HttpClient 4.0 API would be
alright? Also, I confirmed with that change, HttpClient-Cache works in
Android (the jar, that is) and the compiled jar only uses HttpClient 4.0
APIs. The unit tests, however, use methods from beyond the 4.0 API and thus
do not run against HttpClient 4.0.


olegk wrote:
> 
> On Thu, Nov 10, 2011 at 11:49:09AM -0800, candrews wrote:
>> 
>> I thought of that, but it won't work when an Android app has dependencies
>> that use HttpClient.
>> 
>> I use Spring Android Rest Template. My goal is to use Rest Template with
>> caching via HttpClient-Cache. If I shade HttpClient (and
>> HttpClient-Cache),
>> and include the shaded jar in my project, then Rest Template will not use
>> it
>> (as it's compiled to use the "real" HttpClient, not my private copy in a
>> new
>> namespace). So now I have to process Rest Template using Maven Shade. I'd
>> also like osmdroid to use the same HttpClient, so I have to shade it
>> too...
>> Now I'm using at least 4 custom created jar's outside of my Android app's
>> ant build system, causing a serious maintenance problem :-)
>> 
>> Is there an ant analogue to Maven Shade? Is there a different approach to
>> solving these problems?
>> 
> 
> There is a way to build a reasonably up-to-date version of HttpClient
> fully compatible with Android: shade impl classes and new interfaces only
> and make them compileable against 4.0 API. That would involve a bit more
> work but result in a library fully compatible with Android and 3rd party
> libraries at the same time.
> 
> If someone were to contribute such a port to the project, we probably
> could even ship it as an official ASF release.
> 
> Oleg
> 
> 
> 
>> (I apologize if I'm hijacking this list inappropriately - IMHO this seems
>> relevant to httpclient-user, and I'm not sure where else to ask. I'll
>> happily shut up if the list maintainer believes this thread is
>> off-topic).
>> 
>> Thanks again!
>> ~Craig
>> 
>> 
>> sebb-2-2 wrote:
>> > 
>> > On 9 November 2011 04:05, candrews <ca...@integralblue.com> wrote:
>> >>
>> >> Maven Shade isn't compatible with maven-android-plugin:
>> >> https://code.google.com/p/maven-android-plugin/issues/detail?id=170
>> >> Perhaps
>> >> when that is resolved, Shade will be a solution for Maven users. But
>> what
>> >> about Ant users (which I think are what most of the Android apps are
>> >> built
>> >> with)?
>> > 
>> > It would also be possible to use the Maven Shade plugin to create a
>> > version of the HC jars with a different package name.
>> > This would be done independently of any Android build, whether using
>> > Maven or Ant.
>> > 
>> > You then build the Android stuff against the shaded jar, using the new
>> > package names.
>> > 
>> > This is not an ideal long-term solution, but should be sufficient for
>> > prototyping purposes.
>> > 
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> > For additional commands, e-mail: httpclient-users-help@hc.apache.org
>> > 
>> > 
>> > 
>> 
>> -- 
>> View this message in context:
>> http://old.nabble.com/HttpClient-Cache-release-that-works-against-HttpClient-4.0--tp32775131p32821369.html
>> Sent from the HttpClient-User mailing list archive at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/HttpClient-Cache-release-that-works-against-HttpClient-4.0--tp32775131p32826896.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


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


Fully Android compatible HttpClient 4.1.x; was Re: HttpClient-Cache release that works against HttpClient 4.0?

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, Nov 10, 2011 at 11:49:09AM -0800, candrews wrote:
> 
> I thought of that, but it won't work when an Android app has dependencies
> that use HttpClient.
> 
> I use Spring Android Rest Template. My goal is to use Rest Template with
> caching via HttpClient-Cache. If I shade HttpClient (and HttpClient-Cache),
> and include the shaded jar in my project, then Rest Template will not use it
> (as it's compiled to use the "real" HttpClient, not my private copy in a new
> namespace). So now I have to process Rest Template using Maven Shade. I'd
> also like osmdroid to use the same HttpClient, so I have to shade it too...
> Now I'm using at least 4 custom created jar's outside of my Android app's
> ant build system, causing a serious maintenance problem :-)
> 
> Is there an ant analogue to Maven Shade? Is there a different approach to
> solving these problems?
> 

There is a way to build a reasonably up-to-date version of HttpClient fully compatible with Android: shade impl classes and new interfaces only and make them compileable against 4.0 API. That would involve a bit more work but result in a library fully compatible with Android and 3rd party libraries at the same time.

If someone were to contribute such a port to the project, we probably could even ship it as an official ASF release.

Oleg



> (I apologize if I'm hijacking this list inappropriately - IMHO this seems
> relevant to httpclient-user, and I'm not sure where else to ask. I'll
> happily shut up if the list maintainer believes this thread is off-topic).
> 
> Thanks again!
> ~Craig
> 
> 
> sebb-2-2 wrote:
> > 
> > On 9 November 2011 04:05, candrews <ca...@integralblue.com> wrote:
> >>
> >> Maven Shade isn't compatible with maven-android-plugin:
> >> https://code.google.com/p/maven-android-plugin/issues/detail?id=170
> >> Perhaps
> >> when that is resolved, Shade will be a solution for Maven users. But what
> >> about Ant users (which I think are what most of the Android apps are
> >> built
> >> with)?
> > 
> > It would also be possible to use the Maven Shade plugin to create a
> > version of the HC jars with a different package name.
> > This would be done independently of any Android build, whether using
> > Maven or Ant.
> > 
> > You then build the Android stuff against the shaded jar, using the new
> > package names.
> > 
> > This is not an ideal long-term solution, but should be sufficient for
> > prototyping purposes.
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> > 
> > 
> > 
> 
> -- 
> View this message in context: http://old.nabble.com/HttpClient-Cache-release-that-works-against-HttpClient-4.0--tp32775131p32821369.html
> Sent from the HttpClient-User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 

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


Re: HttpClient-Cache release that works against HttpClient 4.0?

Posted by candrews <ca...@integralblue.com>.
I thought of that, but it won't work when an Android app has dependencies
that use HttpClient.

I use Spring Android Rest Template. My goal is to use Rest Template with
caching via HttpClient-Cache. If I shade HttpClient (and HttpClient-Cache),
and include the shaded jar in my project, then Rest Template will not use it
(as it's compiled to use the "real" HttpClient, not my private copy in a new
namespace). So now I have to process Rest Template using Maven Shade. I'd
also like osmdroid to use the same HttpClient, so I have to shade it too...
Now I'm using at least 4 custom created jar's outside of my Android app's
ant build system, causing a serious maintenance problem :-)

Is there an ant analogue to Maven Shade? Is there a different approach to
solving these problems?

(I apologize if I'm hijacking this list inappropriately - IMHO this seems
relevant to httpclient-user, and I'm not sure where else to ask. I'll
happily shut up if the list maintainer believes this thread is off-topic).

Thanks again!
~Craig


sebb-2-2 wrote:
> 
> On 9 November 2011 04:05, candrews <ca...@integralblue.com> wrote:
>>
>> Maven Shade isn't compatible with maven-android-plugin:
>> https://code.google.com/p/maven-android-plugin/issues/detail?id=170
>> Perhaps
>> when that is resolved, Shade will be a solution for Maven users. But what
>> about Ant users (which I think are what most of the Android apps are
>> built
>> with)?
> 
> It would also be possible to use the Maven Shade plugin to create a
> version of the HC jars with a different package name.
> This would be done independently of any Android build, whether using
> Maven or Ant.
> 
> You then build the Android stuff against the shaded jar, using the new
> package names.
> 
> This is not an ideal long-term solution, but should be sufficient for
> prototyping purposes.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/HttpClient-Cache-release-that-works-against-HttpClient-4.0--tp32775131p32821369.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


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


Re: HttpClient-Cache release that works against HttpClient 4.0?

Posted by sebb <se...@gmail.com>.
On 9 November 2011 04:05, candrews <ca...@integralblue.com> wrote:
>
> Maven Shade isn't compatible with maven-android-plugin:
> https://code.google.com/p/maven-android-plugin/issues/detail?id=170 Perhaps
> when that is resolved, Shade will be a solution for Maven users. But what
> about Ant users (which I think are what most of the Android apps are built
> with)?

It would also be possible to use the Maven Shade plugin to create a
version of the HC jars with a different package name.
This would be done independently of any Android build, whether using
Maven or Ant.

You then build the Android stuff against the shaded jar, using the new
package names.

This is not an ideal long-term solution, but should be sufficient for
prototyping purposes.

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


Re: HttpClient-Cache release that works against HttpClient 4.0?

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, 2011-11-08 at 20:05 -0800, candrews wrote:
> Maven Shade isn't compatible with maven-android-plugin:
> https://code.google.com/p/maven-android-plugin/issues/detail?id=170 Perhaps
> when that is resolved, Shade will be a solution for Maven users. But what
> about Ant users (which I think are what most of the Android apps are built
> with)?
> 
> Not to mention that the permanently crippled HttpClient situation in Android
> is incredibly frustrating, unfortunate, and sad for both Android and
> HttpClient - it's a rude awakening for developers who happen to run across
> this problem (I bet many will over the upcoming years!).

> ~Craig
> 
> 

If you find the situation frustrating, just imaging how I feel about it.
I am that very witless idiot who advocated rushing API freeze for
HttpClient in order to make it easier for Google to upgrade HttpClient
shipped with Android. As a result not only did we end up with an
outdated fork of HttpClient ALPHA in Android but also with a suboptimal
API I now wish we had had more time to polish.

Oleg



> sebb-2-2 wrote:
> > 
> > On 8 November 2011 20:14, candrews <ca...@integralblue.com> wrote:
> >>
> >> There are a number of issues with Java's HttpUrlConnection that make it a
> >> less than ideal option compared to HttpClient. For example,
> >> HttpUrlConnection has no way to set default connection/socket timeouts -
> >> you
> >> have to call
> >> http://developer.android.com/reference/java/net/URLConnection.html#setConnectTimeout%28int%29
> >> and
> >> http://developer.android.com/reference/java/net/URLConnection.html#setReadTimeout%28int%29
> >> for every connection. This particular issue is a killer for me - and I
> >> only
> >> just started evaluating switching my apps to HttpUrlConnection.
> >>
> >> There is precedent for Android "breaking" apps with upgrades - for
> >> example,
> >> https://code.google.com/p/android/issues/detail?id=15022 broke quite a
> >> few
> >> apps and annoyed more than a couple developers.
> >>
> >> In any case, I don't want to hijack this thread into a request for
> >> Android
> >> to upgrade HttpClient - I really just want to use HttpClient (and
> >> HttpClient-Cache) on Android.
> >>
> >> Since the org.apache.httpclient namespace is (probably) permanently taken
> >> with an outdated implementation, what can be done to allow Android
> >> developers to use HttpClient?
> >>
> >> Could there be releases, concurrent with the "normal" releases, of the
> >> org.apache.httpclient.* projects renamed to an alternative namespace? Of
> >> course, that means that non-httpclient projects would be broken, as they
> >> wouldn't change to use that alternative namespace, so developers wouldn't
> >> simply be able to drop in dependencies originally developed for
> >> non-Android
> >> targets. And if they did, they'd be in for a surprise when the dependency
> >> doesn't work due to VerifyError's or simply encountering runtime bugs
> >> that
> >> they "know" were fixed as they included a newer HttpClient dependency,
> >> but
> >> it's not actually used.
> >>
> >> IMHO, it seems that the Android decision to never change their bundled
> >> httpclient torpedos httpclient on Android forever - at least until Apache
> >> releases HttpClient 5 that uses a new namespace. Are there any other
> >> ideas
> >> on what can be done to remedy this situation?
> > 
> > Have you considered the Maven Shade plugin?
> > 
> > AIUI, that allows one to rename packages within a jar.
> > So you could change HC to use a different package name and thus use HC
> > 4.1 on Android without clashing with the native classes.
> > 
> > I've only used it to allow Clirr to be used across a package rename,
> > but I think it is quite flexible.
> > 
> > I think you can develop everything using standard package names, then
> > use Shade to rename whatever packages would clash with Android.
> > 
> > Certainly worth trying if you have access to an Android development
> > system.
> > 
> >> Thanks,
> >> ~Craig
> >>
> >>
> >> Jesse Wilson-4 wrote:
> >>>
> >>> Apache HTTP folks,
> >>>
> >>>> I have no problem with making httpclient-cache compatible with Android
> >>>> but at the same time I think users we should be encouraging Android
> >>>> users to migrate to the latest release of HttpClient nonetheless.
> >>>
> >>> I'm the
> >>> maintainer<http://android-developers.blogspot.com/2011/09/androids-http-clients.html>of
> >>> Android's HTTP clients. Android's non-adoption of new versions of
> >>> Apache
> >>> HTTP client is my decision, but it hasn't been an easy one.
> >>>
> >>> We made a mistake early on by exposing the full Apache HTTP client
> >>> API—including
> >>> impl<http://developer.android.com/reference/org/apache/http/impl/cookie/package-summary.html>packages
> >>> —in Android's API. This makes upgrading Apache HTTP client risky as I
> >>> have
> >>> to avoid breaking applications. It also adds a burden on application
> >>> developers who would need to test their applications against multiple
> >>> releases of Apache HTTP client to support multiple releases of Android.
> >>> The
> >>> rich API means there's many moving parts to test.
> >>>
> >>> If I could put the genie back in the bottle I would not have exposed
> >>> Apache
> >>> HTTP as a public API in Android. It's a great API, but our including it
> >>> the
> >>> platform locks everyone into an old build that we grabbed back in 2008.
> >>> It's much simpler for developers to pick a single release, test it, and
> >>> bundle it. For this reason I recommend that developers looking for new
> >>> Apache HTTP features follow Oleg's advice and repackage Apache HTTP in
> >>> their application.
> >>>
> >>> Or use HttpURLConnection, which I've spent a lot of time on lately.
> >>> There's
> >>> even an HTTP response cache in Ice Cream Sandwich.
> >>>
> >>> Thanks Oleg & Apache HTTP client contributors. It's powerful software
> >>> that
> >>> gets lots of exercise on Android.
> >>>
> >>> Thanks,
> >>> Jesse
> >>>
> >>>
> >>
> >> --
> >> View this message in context:
> >> http://old.nabble.com/HttpClient-Cache-release-that-works-against-HttpClient-4.0--tp32775131p32805637.html
> >> Sent from the HttpClient-User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> >> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> >>
> >>
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> > 
> > 
> > 
> 



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


Re: HttpClient-Cache release that works against HttpClient 4.0?

Posted by candrews <ca...@integralblue.com>.
Maven Shade isn't compatible with maven-android-plugin:
https://code.google.com/p/maven-android-plugin/issues/detail?id=170 Perhaps
when that is resolved, Shade will be a solution for Maven users. But what
about Ant users (which I think are what most of the Android apps are built
with)?

Not to mention that the permanently crippled HttpClient situation in Android
is incredibly frustrating, unfortunate, and sad for both Android and
HttpClient - it's a rude awakening for developers who happen to run across
this problem (I bet many will over the upcoming years!).

~Craig


sebb-2-2 wrote:
> 
> On 8 November 2011 20:14, candrews <ca...@integralblue.com> wrote:
>>
>> There are a number of issues with Java's HttpUrlConnection that make it a
>> less than ideal option compared to HttpClient. For example,
>> HttpUrlConnection has no way to set default connection/socket timeouts -
>> you
>> have to call
>> http://developer.android.com/reference/java/net/URLConnection.html#setConnectTimeout%28int%29
>> and
>> http://developer.android.com/reference/java/net/URLConnection.html#setReadTimeout%28int%29
>> for every connection. This particular issue is a killer for me - and I
>> only
>> just started evaluating switching my apps to HttpUrlConnection.
>>
>> There is precedent for Android "breaking" apps with upgrades - for
>> example,
>> https://code.google.com/p/android/issues/detail?id=15022 broke quite a
>> few
>> apps and annoyed more than a couple developers.
>>
>> In any case, I don't want to hijack this thread into a request for
>> Android
>> to upgrade HttpClient - I really just want to use HttpClient (and
>> HttpClient-Cache) on Android.
>>
>> Since the org.apache.httpclient namespace is (probably) permanently taken
>> with an outdated implementation, what can be done to allow Android
>> developers to use HttpClient?
>>
>> Could there be releases, concurrent with the "normal" releases, of the
>> org.apache.httpclient.* projects renamed to an alternative namespace? Of
>> course, that means that non-httpclient projects would be broken, as they
>> wouldn't change to use that alternative namespace, so developers wouldn't
>> simply be able to drop in dependencies originally developed for
>> non-Android
>> targets. And if they did, they'd be in for a surprise when the dependency
>> doesn't work due to VerifyError's or simply encountering runtime bugs
>> that
>> they "know" were fixed as they included a newer HttpClient dependency,
>> but
>> it's not actually used.
>>
>> IMHO, it seems that the Android decision to never change their bundled
>> httpclient torpedos httpclient on Android forever - at least until Apache
>> releases HttpClient 5 that uses a new namespace. Are there any other
>> ideas
>> on what can be done to remedy this situation?
> 
> Have you considered the Maven Shade plugin?
> 
> AIUI, that allows one to rename packages within a jar.
> So you could change HC to use a different package name and thus use HC
> 4.1 on Android without clashing with the native classes.
> 
> I've only used it to allow Clirr to be used across a package rename,
> but I think it is quite flexible.
> 
> I think you can develop everything using standard package names, then
> use Shade to rename whatever packages would clash with Android.
> 
> Certainly worth trying if you have access to an Android development
> system.
> 
>> Thanks,
>> ~Craig
>>
>>
>> Jesse Wilson-4 wrote:
>>>
>>> Apache HTTP folks,
>>>
>>>> I have no problem with making httpclient-cache compatible with Android
>>>> but at the same time I think users we should be encouraging Android
>>>> users to migrate to the latest release of HttpClient nonetheless.
>>>
>>> I'm the
>>> maintainer<http://android-developers.blogspot.com/2011/09/androids-http-clients.html>of
>>> Android's HTTP clients. Android's non-adoption of new versions of
>>> Apache
>>> HTTP client is my decision, but it hasn't been an easy one.
>>>
>>> We made a mistake early on by exposing the full Apache HTTP client
>>> API—including
>>> impl<http://developer.android.com/reference/org/apache/http/impl/cookie/package-summary.html>packages
>>> —in Android's API. This makes upgrading Apache HTTP client risky as I
>>> have
>>> to avoid breaking applications. It also adds a burden on application
>>> developers who would need to test their applications against multiple
>>> releases of Apache HTTP client to support multiple releases of Android.
>>> The
>>> rich API means there's many moving parts to test.
>>>
>>> If I could put the genie back in the bottle I would not have exposed
>>> Apache
>>> HTTP as a public API in Android. It's a great API, but our including it
>>> the
>>> platform locks everyone into an old build that we grabbed back in 2008.
>>> It's much simpler for developers to pick a single release, test it, and
>>> bundle it. For this reason I recommend that developers looking for new
>>> Apache HTTP features follow Oleg's advice and repackage Apache HTTP in
>>> their application.
>>>
>>> Or use HttpURLConnection, which I've spent a lot of time on lately.
>>> There's
>>> even an HTTP response cache in Ice Cream Sandwich.
>>>
>>> Thanks Oleg & Apache HTTP client contributors. It's powerful software
>>> that
>>> gets lots of exercise on Android.
>>>
>>> Thanks,
>>> Jesse
>>>
>>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/HttpClient-Cache-release-that-works-against-HttpClient-4.0--tp32775131p32805637.html
>> Sent from the HttpClient-User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/HttpClient-Cache-release-that-works-against-HttpClient-4.0--tp32775131p32808593.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


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


Re: HttpClient-Cache release that works against HttpClient 4.0?

Posted by sebb <se...@gmail.com>.
On 8 November 2011 20:14, candrews <ca...@integralblue.com> wrote:
>
> There are a number of issues with Java's HttpUrlConnection that make it a
> less than ideal option compared to HttpClient. For example,
> HttpUrlConnection has no way to set default connection/socket timeouts - you
> have to call
> http://developer.android.com/reference/java/net/URLConnection.html#setConnectTimeout%28int%29
> and
> http://developer.android.com/reference/java/net/URLConnection.html#setReadTimeout%28int%29
> for every connection. This particular issue is a killer for me - and I only
> just started evaluating switching my apps to HttpUrlConnection.
>
> There is precedent for Android "breaking" apps with upgrades - for example,
> https://code.google.com/p/android/issues/detail?id=15022 broke quite a few
> apps and annoyed more than a couple developers.
>
> In any case, I don't want to hijack this thread into a request for Android
> to upgrade HttpClient - I really just want to use HttpClient (and
> HttpClient-Cache) on Android.
>
> Since the org.apache.httpclient namespace is (probably) permanently taken
> with an outdated implementation, what can be done to allow Android
> developers to use HttpClient?
>
> Could there be releases, concurrent with the "normal" releases, of the
> org.apache.httpclient.* projects renamed to an alternative namespace? Of
> course, that means that non-httpclient projects would be broken, as they
> wouldn't change to use that alternative namespace, so developers wouldn't
> simply be able to drop in dependencies originally developed for non-Android
> targets. And if they did, they'd be in for a surprise when the dependency
> doesn't work due to VerifyError's or simply encountering runtime bugs that
> they "know" were fixed as they included a newer HttpClient dependency, but
> it's not actually used.
>
> IMHO, it seems that the Android decision to never change their bundled
> httpclient torpedos httpclient on Android forever - at least until Apache
> releases HttpClient 5 that uses a new namespace. Are there any other ideas
> on what can be done to remedy this situation?

Have you considered the Maven Shade plugin?

AIUI, that allows one to rename packages within a jar.
So you could change HC to use a different package name and thus use HC
4.1 on Android without clashing with the native classes.

I've only used it to allow Clirr to be used across a package rename,
but I think it is quite flexible.

I think you can develop everything using standard package names, then
use Shade to rename whatever packages would clash with Android.

Certainly worth trying if you have access to an Android development system.

> Thanks,
> ~Craig
>
>
> Jesse Wilson-4 wrote:
>>
>> Apache HTTP folks,
>>
>>> I have no problem with making httpclient-cache compatible with Android
>>> but at the same time I think users we should be encouraging Android
>>> users to migrate to the latest release of HttpClient nonetheless.
>>
>> I'm the
>> maintainer<http://android-developers.blogspot.com/2011/09/androids-http-clients.html>of
>> Android's HTTP clients. Android's non-adoption of new versions of
>> Apache
>> HTTP client is my decision, but it hasn't been an easy one.
>>
>> We made a mistake early on by exposing the full Apache HTTP client
>> API—including
>> impl<http://developer.android.com/reference/org/apache/http/impl/cookie/package-summary.html>packages
>> —in Android's API. This makes upgrading Apache HTTP client risky as I have
>> to avoid breaking applications. It also adds a burden on application
>> developers who would need to test their applications against multiple
>> releases of Apache HTTP client to support multiple releases of Android.
>> The
>> rich API means there's many moving parts to test.
>>
>> If I could put the genie back in the bottle I would not have exposed
>> Apache
>> HTTP as a public API in Android. It's a great API, but our including it
>> the
>> platform locks everyone into an old build that we grabbed back in 2008.
>> It's much simpler for developers to pick a single release, test it, and
>> bundle it. For this reason I recommend that developers looking for new
>> Apache HTTP features follow Oleg's advice and repackage Apache HTTP in
>> their application.
>>
>> Or use HttpURLConnection, which I've spent a lot of time on lately.
>> There's
>> even an HTTP response cache in Ice Cream Sandwich.
>>
>> Thanks Oleg & Apache HTTP client contributors. It's powerful software that
>> gets lots of exercise on Android.
>>
>> Thanks,
>> Jesse
>>
>>
>
> --
> View this message in context: http://old.nabble.com/HttpClient-Cache-release-that-works-against-HttpClient-4.0--tp32775131p32805637.html
> Sent from the HttpClient-User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

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


Re: HttpClient-Cache release that works against HttpClient 4.0?

Posted by candrews <ca...@integralblue.com>.
There are a number of issues with Java's HttpUrlConnection that make it a
less than ideal option compared to HttpClient. For example,
HttpUrlConnection has no way to set default connection/socket timeouts - you
have to call
http://developer.android.com/reference/java/net/URLConnection.html#setConnectTimeout%28int%29
and
http://developer.android.com/reference/java/net/URLConnection.html#setReadTimeout%28int%29
for every connection. This particular issue is a killer for me - and I only
just started evaluating switching my apps to HttpUrlConnection.

There is precedent for Android "breaking" apps with upgrades - for example,
https://code.google.com/p/android/issues/detail?id=15022 broke quite a few
apps and annoyed more than a couple developers.

In any case, I don't want to hijack this thread into a request for Android
to upgrade HttpClient - I really just want to use HttpClient (and
HttpClient-Cache) on Android.

Since the org.apache.httpclient namespace is (probably) permanently taken
with an outdated implementation, what can be done to allow Android
developers to use HttpClient?

Could there be releases, concurrent with the "normal" releases, of the
org.apache.httpclient.* projects renamed to an alternative namespace? Of
course, that means that non-httpclient projects would be broken, as they
wouldn't change to use that alternative namespace, so developers wouldn't
simply be able to drop in dependencies originally developed for non-Android
targets. And if they did, they'd be in for a surprise when the dependency
doesn't work due to VerifyError's or simply encountering runtime bugs that
they "know" were fixed as they included a newer HttpClient dependency, but
it's not actually used.

IMHO, it seems that the Android decision to never change their bundled
httpclient torpedos httpclient on Android forever - at least until Apache
releases HttpClient 5 that uses a new namespace. Are there any other ideas
on what can be done to remedy this situation?

Thanks,
~Craig


Jesse Wilson-4 wrote:
> 
> Apache HTTP folks,
> 
>> I have no problem with making httpclient-cache compatible with Android
>> but at the same time I think users we should be encouraging Android
>> users to migrate to the latest release of HttpClient nonetheless.
> 
> I'm the
> maintainer<http://android-developers.blogspot.com/2011/09/androids-http-clients.html>of
> Android's HTTP clients. Android's non-adoption of new versions of
> Apache
> HTTP client is my decision, but it hasn't been an easy one.
> 
> We made a mistake early on by exposing the full Apache HTTP client
> API—including
> impl<http://developer.android.com/reference/org/apache/http/impl/cookie/package-summary.html>packages
> —in Android's API. This makes upgrading Apache HTTP client risky as I have
> to avoid breaking applications. It also adds a burden on application
> developers who would need to test their applications against multiple
> releases of Apache HTTP client to support multiple releases of Android.
> The
> rich API means there's many moving parts to test.
> 
> If I could put the genie back in the bottle I would not have exposed
> Apache
> HTTP as a public API in Android. It's a great API, but our including it
> the
> platform locks everyone into an old build that we grabbed back in 2008.
> It's much simpler for developers to pick a single release, test it, and
> bundle it. For this reason I recommend that developers looking for new
> Apache HTTP features follow Oleg's advice and repackage Apache HTTP in
> their application.
> 
> Or use HttpURLConnection, which I've spent a lot of time on lately.
> There's
> even an HTTP response cache in Ice Cream Sandwich.
> 
> Thanks Oleg & Apache HTTP client contributors. It's powerful software that
> gets lots of exercise on Android.
> 
> Thanks,
> Jesse
> 
> 

-- 
View this message in context: http://old.nabble.com/HttpClient-Cache-release-that-works-against-HttpClient-4.0--tp32775131p32805637.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


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


Re: HttpClient-Cache release that works against HttpClient 4.0?

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2011-11-07 at 14:25 +0000, Moore, Jonathan (CIM) wrote:
> Is that really the only change that would be necessary to work with 4.0? I
> think it might be worth double-checking that all the tests pass with this
> change and when compiled against 4.0.
> 
> While I agree that it would be better for Google to be upgrading the
> version of HttpClient they're using, at the same time, there are a lot of
> Android developers and users that would benefit from having the caching
> module. I'm willing to spend a little time to investigate further and
> perhaps make a change like this if it's not going to compromise the
> codebase going forwards.
> 
> At the same time, Craig: couldn't you just apply that diff yourself and
> run with a patched version of httpclient-cache in your apps, then wait
> until Google upgrades the HttpClient that's embedded in Android?
> 

Jon

The trouble is that Google made it quite clear they were not going to
upgrade HttpClient in Android. To make matters worse they will continue
shipping their outdated pre-BETA version with Android for releases to
come. 

I have no problem with making httpclient-cache compatible with Android
but at the same time I think users we should be encouraging Android
users to migrate to the latest release of HttpClient nonetheless. 

Oleg




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


Re: HttpClient-Cache release that works against HttpClient 4.0?

Posted by "Moore, Jonathan (CIM)" <Jo...@Comcast.com>.
Is that really the only change that would be necessary to work with 4.0? I
think it might be worth double-checking that all the tests pass with this
change and when compiled against 4.0.

While I agree that it would be better for Google to be upgrading the
version of HttpClient they're using, at the same time, there are a lot of
Android developers and users that would benefit from having the caching
module. I'm willing to spend a little time to investigate further and
perhaps make a change like this if it's not going to compromise the
codebase going forwards.

At the same time, Craig: couldn't you just apply that diff yourself and
run with a patched version of httpclient-cache in your apps, then wait
until Google upgrades the HttpClient that's embedded in Android?

Jon
........
Jon Moore
Comcast Interactive Media






On 11/3/11 2:32 PM, "candrews" <ca...@integralblue.com> wrote:

>
>HttpClient-Cache doesn't work against HttpClient 4.0 because it uses
>org.apache.http.util.EntityUtils.consume(org.apache.http.HttpEntity) which
>wasn't introduced until HttpClient 4.1.
>
>Since Android uses HttpClient 4.0 (yes, it sucks that they won't upgrade,
>and I don't understand their reasons for not upgrading, but anyways), this
>means you can't use HttpClient-Cache on Android - and IMHO, it would be
>really useful.
>
>Could HttpClient-Cache simply not use
>org.apache.http.util.EntityUtils.consume and therefore set the minimum
>HttpClient version to 4.0? The change seems quite simple - in
>ResponseProtocolCompliance, use this method body instead of the existing
>one:
>
>    private void consumeBody(HttpResponse response) throws IOException {
>        HttpEntity body = response.getEntity();
>        if (body != null){
>         if (body.isStreaming()) {
>             InputStream instream = body.getContent();
>             if (instream != null) {
>                 instream.close();
>             }
>         }
>    }
>
>Thank you,
>~Craig
>-- 
>View this message in context:
>http://old.nabble.com/HttpClient-Cache-release-that-works-against-HttpClie
>nt-4.0--tp32775131p32775131.html
>Sent from the HttpClient-User mailing list archive at Nabble.com.
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>For additional commands, e-mail: httpclient-users-help@hc.apache.org
>


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