Guest User

Untitled

a guest
Feb 18th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. Boolean htaccess = b.getBoolean("htaccess");
  2. final String htuser = b.getString("htuser");
  3. final String htpass = b.getString("htpass");
  4.  
  5. try{
  6. HttpGet httpGet = new HttpGet(url.toURI());
  7. DefaultHttpClient httpclient = new DefaultHttpClient();
  8. if ( htaccess = true ) {
  9. Credentials creds = new UsernamePasswordCredentials(htuser, htpass);
  10. httpclient.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), creds);
  11. }
  12. HttpResponse response = httpclient.execute(httpGet);
  13. httpcontent = response.getEntity().getContent();
  14. BufferedReader rd = new BufferedReader(new InputStreamReader(httpcontent), 4096);
  15. String line;
  16. StringBuilder sb = new StringBuilder();
  17. while ((line = rd.readLine()) != null) {
  18. sb.append(line);
  19. }
  20. rd.close();
  21. reply = new String(sb.toString());
  22. } catch (Exception e) {
  23. Toast.makeText(getBaseContext(), "Invalid URL", Toast.LENGTH_SHORT);
  24. }
  25.  
  26. Log.v("Clients", reply);
Add Comment
Please, Sign In to add comment