Java Code Examples for cz.msebera.android.httpclient.HttpResponse#getEntity()
The following examples show how to use
cz.msebera.android.httpclient.HttpResponse#getEntity() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NetWorkTool.java From FoodOrdering with Apache License 2.0 | 6 votes |
public static String getContent(String url) throws Exception { StringBuilder sb = new StringBuilder(); HttpClient client = new DefaultHttpClient(); HttpParams httpParams = (HttpParams) client.getParams(); // 设置网络超时参数 HttpConnectionParams.setConnectionTimeout(httpParams, 3000); HttpConnectionParams.setSoTimeout(httpParams, 5000); HttpResponse response = client.execute(new HttpGet(url)); HttpEntity entity = response.getEntity(); if (entity != null) { BufferedReader reader = new BufferedReader(new InputStreamReader( entity.getContent(), "GBK"), 8192); String line = null; while ((line = reader.readLine()) != null) { sb.append(line); } reader.close(); } return sb.toString(); }
Example 2
Source File: FeedFragment.java From Instagram-Profile-Downloader with MIT License | 5 votes |
@Override protected String doInBackground(Void... params) { HttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url); try { HttpResponse response = httpClient.execute(httpGet); HttpEntity httpEntity = response.getEntity(); return EntityUtils.toString(httpEntity); } catch (IOException e) { e.printStackTrace(); } return null; }
Example 3
Source File: ProfileFragment.java From Instagram-Profile-Downloader with MIT License | 5 votes |
@Override protected String doInBackground(Void... params) { HttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url); try { HttpResponse response = httpClient.execute(httpGet); HttpEntity httpEntity = response.getEntity(); return EntityUtils.toString(httpEntity); } catch (IOException e) { e.printStackTrace(); } return null; }
Example 4
Source File: OverviewDialog.java From Instagram-Profile-Downloader with MIT License | 5 votes |
@Override protected String doInBackground(Void... params) { HttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url); try { HttpResponse response = httpClient.execute(httpGet); HttpEntity httpEntity = response.getEntity(); return EntityUtils.toString(httpEntity); } catch (IOException e) { e.printStackTrace(); } return null; }
Example 5
Source File: MainActivity.java From Instagram-Profile-Downloader with MIT License | 5 votes |
@Override protected String doInBackground(Void... params) { HttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(url); try { HttpResponse response = httpClient.execute(httpGet); HttpEntity httpEntity = response.getEntity(); return EntityUtils.toString(httpEntity); } catch (IOException e) { e.printStackTrace(); } return null; }
Example 6
Source File: MainActivity.java From Instagram-Profile-Downloader with MIT License | 5 votes |
@Override protected String doInBackground(Void... params) { HttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(final_url); try { HttpResponse response = httpClient.execute(httpGet); HttpEntity httpEntity = response.getEntity(); return EntityUtils.toString(httpEntity); } catch (IOException e) { e.printStackTrace(); } return null; }
Example 7
Source File: IntroScreenActivity.java From Instagram-Profile-Downloader with MIT License | 5 votes |
@Override protected String doInBackground(Void... params) { HttpClient httpClient = new DefaultHttpClient(); HttpGet httpGet = new HttpGet(getResources().getString(R.string.get_user_info_url) + token); try { HttpResponse response = httpClient.execute(httpGet); HttpEntity httpEntity = response.getEntity(); return EntityUtils.toString(httpEntity); } catch (IOException e) { e.printStackTrace(); } return null; }
Example 8
Source File: DownloadProfileImageActivity.java From Instagram-Profile-Downloader with MIT License | 5 votes |
@Override protected String doInBackground(Void... params) { HttpClient httpClient = new DefaultHttpClient(); try { HttpGet httpGet = new HttpGet(url); HttpResponse response = httpClient.execute(httpGet); HttpEntity httpEntity = response.getEntity(); return EntityUtils.toString(httpEntity); } catch (Exception e) { e.printStackTrace(); } return null; }
Example 9
Source File: HttpWebConnection.java From HtmlUnit-Android with Apache License 2.0 | 5 votes |
/** * Downloads the response body. * @param httpResponse the web server's response * @return a wrapper for the downloaded body. * @throws IOException in case of problem reading/saving the body */ protected DownloadedContent downloadResponseBody(final HttpResponse httpResponse) throws IOException { final HttpEntity httpEntity = httpResponse.getEntity(); if (httpEntity == null) { return new DownloadedContent.InMemory(null); } try (InputStream is = httpEntity.getContent()) { return downloadContent(is, webClient_.getOptions().getMaxInMemory()); } }
Example 10
Source File: HorochanModule.java From Overchan-Android with GNU General Public License v3.0 | 5 votes |
@Override public String deletePost(DeletePostModel model, ProgressListener listener, CancellableTask task) throws Exception { String url = getUsingUrl(true) + "v1/posts/" + model.postNumber; HttpEntity entity = ExtendedMultipartBuilder.create().setDelegates(listener, task).addString("password", model.password).build(); HttpUriRequest request = null; HttpResponse response = null; HttpEntity responseEntity = null; try { request = RequestBuilder.delete().setUri(url).setEntity(entity).build(); response = httpClient.execute(request); StatusLine status = response.getStatusLine(); switch (status.getStatusCode()) { case 200: return null; case 400: responseEntity = response.getEntity(); InputStream stream = IOUtils.modifyInputStream(responseEntity.getContent(), null, task); JSONObject json = new JSONObject(new JSONTokener(new BufferedReader(new InputStreamReader(stream)))); throw new Exception(json.getString("message")); default: throw new Exception(status.getStatusCode() + " - " + status.getReasonPhrase()); } } finally { try { if (request != null) request.abort(); } catch (Exception e) {} EntityUtils.consumeQuietly(responseEntity); if (response != null && response instanceof Closeable) IOUtils.closeQuietly((Closeable) response); } }