Skip to content

Commit

Permalink
调用超时时间设置10s
Browse files Browse the repository at this point in the history
  • Loading branch information
xueli.xue committed May 4, 2017
1 parent fc5b6fa commit 09aad11
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.ContentType;
Expand Down Expand Up @@ -39,6 +40,12 @@ public static byte[] postRequest(String reqURL, byte[] date) throws Exception {
}
httpPost.setEntity(new UrlEncodedFormEntity(formParams, "UTF-8"));
}*/

// timeout
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(10000).setConnectTimeout(10000).build();
httpPost.setConfig(requestConfig);

// data
if (date != null) {
httpPost.setEntity(new ByteArrayEntity(date, ContentType.DEFAULT_BINARY));
}
Expand Down

0 comments on commit 09aad11

Please sign in to comment.