List of usage examples for org.apache.http.impl.client DefaultHttpClient removeRequestInterceptorByClass
public synchronized void removeRequestInterceptorByClass(final Class<? extends HttpRequestInterceptor> clazz)
From source file:no.lookout.incontrol.ModuleUtil.java
public static JSONObject postModuleData(HttpParams httpParams, String uri, String userName, String password, List<BasicNameValuePair> fields) throws ClientProtocolException, IOException, JSONException { DefaultHttpClient httpClient = new DefaultHttpClient(httpParams); httpClient.removeRequestInterceptorByClass(org.apache.http.protocol.RequestExpectContinue.class); HttpPost httpPost = new HttpPost(uri); if (userName != null && userName.length() > 0 && password != null && password.length() > 0) { httpPost.addHeader("Authorization", "Basic " + Base64.encodeBytes((userName + ":" + password).getBytes())); }/*from w w w . jav a 2s .c o m*/ try { httpPost.setEntity(new UrlEncodedFormEntity(fields)); HttpResponse response = httpClient.execute(httpPost); HttpEntity entity = response.getEntity(); if (entity != null) { InputStream instream = entity.getContent(); JSONObject jsonObject = new JSONObject(streamToString(instream)); instream.close(); return jsonObject; } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return null; }