Search in sources :

Example 1 with DefaultHttpClient

use of com.bluenimble.platform.http.impls.DefaultHttpClient in project serverless by bluenimble.

the class SimpleGetRequest method main.

public static void main(String[] args) throws Exception {
    DefaultHttpClient client = new DefaultHttpClient();
    GetRequest request = new GetRequest(HttpUtils.createEndpoint(new URI("https://api.indix.com/v2/summary/products?countryCode=US&app_id=2a4049dd&app_key=444978937e94a8adebdcd701660da344")));
    request.getParameters().add(new HttpParameterImpl("q", "hello kitty"));
    HttpResponse response = client.send(request);
    response.getBody().dump(System.out, "utf-8", null);
}
Also used : HttpParameterImpl(com.bluenimble.platform.http.impls.HttpParameterImpl) GetRequest(com.bluenimble.platform.http.request.impls.GetRequest) HttpResponse(com.bluenimble.platform.http.response.HttpResponse) URI(java.net.URI) DefaultHttpClient(com.bluenimble.platform.http.impls.DefaultHttpClient)

Example 2 with DefaultHttpClient

use of com.bluenimble.platform.http.impls.DefaultHttpClient in project serverless by bluenimble.

the class UseProxyRequest method main.

public static void main(String[] args) throws Exception {
    DefaultHttpClient client = new DefaultHttpClient();
    GetRequest request = new GetRequest(HttpUtils.createEndpoint(new URI("http://amazon.com/Apple-Retina-display-MD510LL-9-7-Inch/dp/B009W8YQ6K/ref=sr_1_1?s=pc&ie=UTF8&qid=1414360465&sr=1-1&keywords=ipad")));
    request.setProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("us-il.proxymesh.com", 31280)));
    HttpResponse response = null;
    for (int i = 0; i < 50; i++) {
        response = client.send(request);
        System.out.println(response.getStatus());
    }
}
Also used : Proxy(java.net.Proxy) InetSocketAddress(java.net.InetSocketAddress) GetRequest(com.bluenimble.platform.http.request.impls.GetRequest) HttpResponse(com.bluenimble.platform.http.response.HttpResponse) URI(java.net.URI) DefaultHttpClient(com.bluenimble.platform.http.impls.DefaultHttpClient)

Aggregations

DefaultHttpClient (com.bluenimble.platform.http.impls.DefaultHttpClient)2 GetRequest (com.bluenimble.platform.http.request.impls.GetRequest)2 HttpResponse (com.bluenimble.platform.http.response.HttpResponse)2 URI (java.net.URI)2 HttpParameterImpl (com.bluenimble.platform.http.impls.HttpParameterImpl)1 InetSocketAddress (java.net.InetSocketAddress)1 Proxy (java.net.Proxy)1