代码如下 | 复制代码 |
private HttpPost getHttpPost(String url, byte[] voiceContent, int totalRetryTimes) { HttpPost httpPost = new HttpPost(POST_URL); httpPost.setHeader("Accept-Charset", "GBK"); httpPost.setHeader("Accept-Encoding", HTTP.IDENTITY_CODING); // set value for S-COOKIE, add by yuanbin on 2013-08-08 // update on 2013-10-03 // add totalRetryTimes on 2013-10-21 String originalCookie = "************cookie secret**********"; // get synchronized encrypted S-COOKIE, 2013-12-04 httpPost.setHeader("S-COOKIE", myMainProcess.getSyncEncScookie(originalCookie)); if (voiceContent != null) { //ByteArrayEntity arrayEntity = new ByteArrayEntity(voiceContent); httpPost.setEntity(new ByteArrayEntity(voiceContent)); } return httpPost; } public HttpClient getHttpClient() { HttpParams httpParams = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParams, CONNECTION_TIME_OUT); if (sequenceNo < 0) { HttpConnectionParams.setSoTimeout(httpParams, FINAL_READ_TIME_OUT); } else { HttpConnectionParams.setSoTimeout(httpParams, this.readTimeout); } HttpConnectionParams.setTcpNoDelay(httpParams, true); httpParams.setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE,false); HttpClient httpClient = new DefaultHttpClient(httpParams); //httpClient.getParams().setBooleanParameter(arg0, arg1) return httpClient; } |
时间: 2024-12-22 14:43:43