使用DefaultHttpClient发送HTTP POST时出现不可预测的结果

时间:2015-06-25 11:31:43

标签: java json post httpresponse

我正在使用letters_list = [0,1,2,3,10,11] def check_letter(ProductCode): global letters_list for l in letters_list: if not ProductCode[l].isalpha: return False return True if check_letter(ProductCode): print("Everything in list is a letter") #define ProductCode else: print("Something is wrong") 发送包含json原始数据的HTTP POST请求:

DefaultHttpClient

我正在使用它发送5个请求,结果必须是json-raw-response,尽管我得到的是前两个响应,但其他三个我得到的是一个HTML代码网页:

DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost httppostreq = new HttpPost(post_url);

StringEntity se = new StringEntity(json.toString()); // json is my JSONObject

se.setContentType("application/json;charset=UTF-8"); 
se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,"application/json;charset=UTF-8"));

httppostreq.setEntity(se);

HttpResponse httpresponse = httpclient.execute(httppostreq);

String responseText = EntityUtils.toString(httpresponse.getEntity());

那么,是什么能让我得出这个结果以及我的工作中可能出现的问题呢?

0 个答案:

没有答案