I used to have this code working with my Tomcat server:
HttpRequestBase targetRequest = ...;
HttpResponse targetResponse = httpclient.execute(targetRequest);
HttpEntity entity = targetResponse.getEntity();
However when I migrated with Google App Engine, I can’ use this code anymore. So I read a bit and found that I need to use another code to achieve this.
So I have this code:
URLFetchService fetcher = URLFetchServiceFactory.getURLFetchService();
HTTPResponse targetRespose = fetcher.fetch(targetRequest); // Error
HttpEntity entity = targetResponse.getEntity();
However its obvious that there’s an error with the fetcher.fetch code.
All I need to accomplish to to have the same HttpEntity using App Engine approach. Any way to work this out?
org.apache.http.HttpRequestandcom.google.appengine.api.urlfetch.HTTPRequestare two totally different classes from two different libraries, so you can not just exchange one for the other.If you’d like to use Apache HttpClient on GAE, it can be done with some workarounds: see here and here.