Skip to content

Instantly share code, notes, and snippets.

View ironcamel's full-sized avatar

Naveed Massjouni ironcamel

  • Blacksburg, VA, USA
View GitHub Profile
use LWP::UserAgent;
my $agent = LWP::UserAgent->new();
$agent->credentials($host, $realm, $user, $pass);
print $agent->get($uri)->content();
@ironcamel
ironcamel / SimpleRequest.java
Created October 27, 2010 04:14
This is a comparison of making a simple http request with basic/digest authentication in perl and java. I was porting a perl app to the android platform (java) and was struck by the different amount of complexity and effort required.
import java.io.BufferedReader;
import java.io.InputStreamReader;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
public class SimpleRequest {