Commit 7e0262bb authored by qinmin's avatar qinmin Committed by Commit bot

Remove java import of org.apache.http

The org.apache.http package is being deprecated.
Android Dev page suggests using HttpURLConnection instead.

BUG=468867

Review URL: https://codereview.chromium.org/1023033002

Cr-Commit-Position: refs/heads/master@{#321906}
parent cd161c6f
...@@ -24,12 +24,6 @@ import android.view.LayoutInflater; ...@@ -24,12 +24,6 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.TextView; import android.widget.TextView;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.chromium.base.ApplicationStatus; import org.chromium.base.ApplicationStatus;
import org.chromium.base.VisibleForTesting; import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.R; import org.chromium.chrome.R;
...@@ -39,11 +33,16 @@ import org.xmlpull.v1.XmlPullParser; ...@@ -39,11 +33,16 @@ import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory; import org.xmlpull.v1.XmlPullParserFactory;
import java.io.DataOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
...@@ -661,34 +660,42 @@ public class OMADownloadHandler { ...@@ -661,34 +660,42 @@ public class OMADownloadHandler {
@Override @Override
protected Boolean doInBackground(Void...voids) { protected Boolean doInBackground(Void...voids) {
HttpClient httpClient = new DefaultHttpClient(); HttpURLConnection urlConnection = null;
HttpPost httpPost = new HttpPost(mOMAInfo.getValue(OMA_INSTALL_NOTIFY_URI));
try { try {
URL url = new URL(mOMAInfo.getValue(OMA_INSTALL_NOTIFY_URI));
urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setDoOutput(true);
urlConnection.setUseCaches(false);
urlConnection.setRequestMethod("POST");
String userAgent = mDownloadInfo.getUserAgent(); String userAgent = mDownloadInfo.getUserAgent();
if (TextUtils.isEmpty(userAgent)) { if (TextUtils.isEmpty(userAgent)) {
userAgent = ChromiumApplication.getBrowserUserAgent(); userAgent = ChromiumApplication.getBrowserUserAgent();
} }
httpPost.setHeader("Accept", "*/*"); urlConnection.setRequestProperty("User-Agent", userAgent);
httpPost.setHeader("User-Agent", userAgent); urlConnection.setRequestProperty("cookie", mDownloadInfo.getCookie());
httpPost.setHeader("Cookie", mDownloadInfo.getCookie());
httpPost.setEntity(new StringEntity(mStatusMessage)); DataOutputStream dos = new DataOutputStream(urlConnection.getOutputStream());
try {
// Execute HTTP Post Request dos.writeBytes(mStatusMessage);
HttpResponse response = httpClient.execute(httpPost); dos.flush();
} catch (IOException e) {
byte[] responseBody; Log.w(TAG, "Cannot write status message.", e);
int responseCode = response.getStatusLine().getStatusCode(); } finally {
dos.close();
}
int responseCode = urlConnection.getResponseCode();
if (responseCode == 200 || responseCode == -1) { if (responseCode == 200 || responseCode == -1) {
return true; return true;
} }
return false; return false;
} catch (ClientProtocolException e) { } catch (MalformedURLException e) {
Log.w(TAG, "Invalid protocol detected.", e); Log.w(TAG, "Invalid notification URL.", e);
} catch (IOException e) { } catch (IOException e) {
Log.w(TAG, "Cannot connect to server.", e); Log.w(TAG, "Cannot connect to server.", e);
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
Log.w(TAG, "Cannot connect to server.", e); Log.w(TAG, "Cannot connect to server.", e);
} finally {
if (urlConnection != null) urlConnection.disconnect();
} }
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment