Skip to content

Use HttpURLConnection instead of the deprecated classes #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 17, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions core/src/processing/core/PApplet.java
Original file line number Diff line number Diff line change
Expand Up @@ -4944,12 +4944,19 @@ public InputStream createInputRaw(String filename) {
// URL url = new URL(filename);
// stream = url.openStream();
// return stream;
HttpGet httpRequest = null;
httpRequest = new HttpGet(URI.create(filename));
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = (HttpResponse) httpclient.execute(httpRequest);
HttpEntity entity = response.getEntity();
return entity.getContent();
URL url = new URL(filename);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
con.setDoInput(true);
con.connect();
return con.getInputStream();
//The following code is deprecaded by Android
// HttpGet httpRequest = null;
// httpRequest = new HttpGet(URI.create(filename));
// HttpClient httpclient = new DefaultHttpClient();
// HttpResponse response = (HttpResponse) httpclient.execute(httpRequest);
// HttpEntity entity = response.getEntity();
// return entity.getContent();
// can't use BufferedHttpEntity because it may try to allocate a byte
// buffer of the size of the download, bad when DL is 25 MB... [0200]
// BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(entity);
Expand Down