号簿助手 v4.6.31版本的 MD5 值为:9d7ff98a6bb5cc178eac2df4d1b2f0e0
以下内容为反编译后的 HttpClientRequest.java 源代码,内容仅作参考
package com.yulore.collect.network;
import android.net.http.AndroidHttpClient;
import android.text.TextUtils;
import com.yulore.collect.log.Logger;
import java.io.IOException;
import java.util.Map;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
public class HttpClientRequest extends Request {
@Override
public boolean performRequest(Map<String, String> params) {
try {
return httpClientPost(params);
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
private boolean httpClientPost(Map<String, String> params) throws IOException {
HttpPost postRequest = new HttpPost("http://stat.dianhua.cn/stat/collect/post.php");
postRequest.addHeader(HTTP.CONTENT_TYPE, getBodyContentType());
byte[] body = encodeParameters(params, getParamsEncoding());
if (body != null) {
HttpEntity entity = new ByteArrayEntity(body);
postRequest.setEntity(entity);
}
HttpParams httpParams = postRequest.getParams();
HttpConnectionParams.setConnectionTimeout(httpParams, 50000);
HttpConnectionParams.setSoTimeout(httpParams, 50000);
HttpClient client = AndroidHttpClient.newInstance("com.yulore.collect");
HttpResponse response = client.execute(postRequest);
int responseCode = response.getStatusLine().getStatusCode();
Logger.d("Request", "HttpClientRequest responseCode: " + responseCode);
if (responseCode != 200) {
return false;
}
String responseData = EntityUtils.toString(response.getEntity());
Logger.d("Request", "HttpClientRequest responseData: " + responseData);
if (TextUtils.isEmpty(responseData)) {
return false;
}
return parserStatus(responseData);
}
}