List of usage examples for org.apache.http.impl.client BasicResponseHandler BasicResponseHandler
BasicResponseHandler
From source file:ch.ethz.sms.androidsms.impl.SMS.java
private void initializeHttpCLient() { mHttpClient = new DefaultHttpClient(); mResponseHandler = new BasicResponseHandler(); mHttpPost = new HttpPost(REQUEST_URL); mPostBodyData = new ArrayList<NameValuePair>(); mPostBodyData.add(new BasicNameValuePair(USERNAME, mUsername)); mPostBodyData.add(new BasicNameValuePair(PASSWORD, mPassword)); }
From source file:com.speakingcode.freemusicarchive.api.FMAConnector.java
/** * Makes the HTTP GET request to the provided REST url * @param requestUrl the URL to request/*from w w w. j a v a 2s .c o m*/ * @return The string of the response from the HTTP request */ public static String callWebService(String requestUrl) { String deviceId = "xxxxx"; HttpClient httpclient = new DefaultHttpClient(); HttpGet request = new HttpGet(requestUrl); request.addHeader("deviceId", deviceId); ResponseHandler<String> handler = new BasicResponseHandler(); String result = ""; try { result = httpclient.execute(request, handler); } catch (ClientProtocolException e) { e.printStackTrace(); Log.e(TAG, "ClientProtocolException in callWebService(). " + e.getMessage()); } catch (IOException e) { e.printStackTrace(); Log.e(TAG, "IOException in callWebService(). " + e.getMessage()); } httpclient.getConnectionManager().shutdown(); Log.i(TAG, "**callWebService() successful. Result: **"); Log.i(TAG, result); Log.i(TAG, "*****************************************"); return result; }
From source file:com.pervasive.sth.network.RESTClient.java
/** * @return//from www .j a va2s . c o m * @throws Exception * @brief Executes HTTP GET on the server URL */ public String executeGet() throws Exception { HttpClient httpClient = new DefaultHttpClient(); HttpGet httpget = new HttpGet(_url); ResponseHandler<String> responseHandler = new BasicResponseHandler(); return httpClient.execute(httpget, responseHandler); }
From source file:org.ow2.proactive_grid_cloud_portal.rm.server.serialization.ExportNodeSourceToCatalogServlet.java
private void postRequestAndHandleResponse(HttpServletResponse response, CatalogObjectAction catalogObjectAction, CatalogRequestBuilder catalogRequestBuilder, String requestUri) throws IOException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException { try (CloseableHttpResponse httpResponse = catalogRequestBuilder .postNodeSourceRequestToCatalog(requestUri)) { new BasicResponseHandler().handleResponse(httpResponse); } catch (HttpResponseException e) { logErrorAndWriteResponseToClient(e, response); }/*from w w w .ja v a2 s .c o m*/ }
From source file:com.nexmo.client.verify.endpoints.VerifyEndpoint.java
@Override public VerifyResult parseResponse(HttpResponse response) throws IOException { return parseVerifyResponse(new BasicResponseHandler().handleResponse(response)); }
From source file:org.ow2.chameleon.fuchsia.push.base.subscriber.tool.HubDiscovery.java
public String getContents(String feed) throws IOException { String response = null;/*from w w w . j a va2s . c o m*/ HttpClient httpclient = new DefaultHttpClient(); HttpGet httpget = new HttpGet(feed); ResponseHandler<String> responseHandler = new BasicResponseHandler(); String responseBody = httpclient.execute(httpget, responseHandler); response = (responseBody); httpclient.getConnectionManager().shutdown(); return response; }
From source file:com.josephblough.sbt.transport.SbaTransport.java
private static LicenseAndPermitDataCollection getLicenseAndPermitData(final String url) { try {/*from www.j ava 2 s . com*/ HttpClient client = new DefaultHttpClient(); Log.d(TAG, "url: " + url); HttpGet httpMethod = new HttpGet(url); ResponseHandler<String> handler = new BasicResponseHandler(); String response = client.execute(httpMethod, handler); JSONObject json = new JSONObject(response); return processLicenseAndPermitData(json); } catch (OutOfMemoryError e) { return null; } catch (Exception e) { Log.e(TAG, e.getMessage(), e); } return null; }
From source file:es.tsb.ltba.nomhad.httpclient.NomhadHttpClient.java
/** * Http POST request./* w ww. j a va 2 s . co m*/ * * @param uri * URI * @param body * body * @return response from server * @throws ClientProtocolException * @throws IOException */ public String post(String uri, String body) throws ClientProtocolException, IOException { HttpPost post = new HttpPost(uri); if (body != null) { post.setEntity(new StringEntity(body)); } ResponseHandler<String> responseHandler = new BasicResponseHandler(); return httpClient.execute(post, responseHandler); }
From source file:net.noday.cat.web.admin.DwzManager.java
public void gendwz(String url, String alias) { HttpClient client = new DefaultHttpClient(); HttpPost post = new HttpPost("http://dwz.cn/create.php"); post.getParams().setParameter("url", url).setParameter("alias", alias); try {/*from ww w.j a v a 2s . c o m*/ ResponseHandler<String> responseHandler = new BasicResponseHandler(); String responseBody = client.execute(post, responseHandler); System.out.println(responseBody); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { client.getConnectionManager().shutdown(); } }
From source file:edu.vt.alerts.android.library.tasks.TermsOfServiceTask.java
/** * {@inheritDoc}/*from w ww. j a v a 2 s .c o m*/ */ @Override protected TaskResult<String> doInBackground(Void... params) { if (PreferenceUtil.hasAcceptedTerms(context, alertsEnvironment)) { return new TaskResult<String>(null, null); } DefaultHttpClient httpClient = new DefaultHttpClient(); HttpGet get = new HttpGet(alertsEnvironment.getTermsOfUseUrl()); ResponseHandler<String> responseHandler = new BasicResponseHandler(); try { HttpResponse response = httpClient.execute(get); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode >= 200 && statusCode < 300) { String tos = responseHandler.handleResponse(response); return new TaskResult<String>(tos, null); } throw new UnexpectedNetworkResponseException( "Unexpected response when attempting to fetch terms of service", statusCode, response.getStatusLine().getReasonPhrase()); } catch (Exception e) { return new TaskResult<String>(null, e); } }