Skip to content

Migrating from Apache HTTP

Jeff Davidson edited this page Dec 27, 2017 · 2 revisions

As of Volley version 1.1.0, Apache HTTP has gone from being required to optional in keeping with the library's deprecation in the Android platform. It is only needed for clients using the Apache HttpClientStack. Existing apps should continue to compile and work with no changes, but apps should be able to remove the dependency, potentially after some minor modifications detailed below.

Most apps using HurlStack or Volley#newRequestQueue with minSdkVersion set to 9 or higher should not need to take any action other than removing the useLibrary 'org.apache.http.legacy' declaration from your build.gradle file if it is present.

For apps which need to support Froyo (API 8) devices, Apache HTTP remains the recommended option due to known issues in HttpUrlConnection. You should continue to use HttpClientStack or Volley#newRequestQueue (which uses HttpClientStack on API 8 devices and HurlStack, based on HttpUrlConnection, on newer devices). Your build.gradle file will need to continue specifying useLibrary 'org.apache.http.legacy'. Note that Volley plans to end support for API 8 devices in an upcoming release in keeping with other Android libraries.

Otherwise, migration instructions are as follows:

  • If your app uses a custom HttpStack implementation, it will need to be migrated to BaseHttpStack. This will entail renaming the performRequest method to executeRequest and changing the return type from Apache's HttpResponse class to Volley's new HttpResponse class. Your code should never call performRequest directly.

  • If your app extends BasicNetwork, the protected mHttpStack field and convertHeaders method have been deprecated and must not be used. Otherwise, be sure to use the new constructors which take BaseHttpStack implementations rather than HttpStack implementations.

  • If your app uses Volley#newRequestQueue, be sure you are passing in a BaseHttpStack instance and not an HttpStack instance.

Clone this wiki locally