Example usage for org.apache.http.impl.client WinHttpClients createDefault

List of usage examples for org.apache.http.impl.client WinHttpClients createDefault

Introduction

In this page you can find the example usage for org.apache.http.impl.client WinHttpClients createDefault.

Prototype

public static CloseableHttpClient createDefault() 

Source Link

Document

Creates CloseableHttpClient instance with default configuration.

Usage

From source file:demo.example.ClientWinAuth.java

public final static void main(String[] args) throws Exception {

    if (!WinHttpClients.isWinAuthAvailable()) {
        System.out.println("Integrated Win auth is not supported!!!");
    }/*from w ww . ja v  a 2 s. c o m*/

    CloseableHttpClient httpclient = WinHttpClients.createDefault();
    // There is no need to provide user credentials
    // HttpClient will attempt to access current user security context through
    // Windows platform specific methods via JNI.
    try {
        HttpGet httpget = new HttpGet("http://winhost/");

        System.out.println("Executing request " + httpget.getRequestLine());
        CloseableHttpResponse response = httpclient.execute(httpget);
        try {
            System.out.println("----------------------------------------");
            System.out.println(response.getStatusLine());
            EntityUtils.consume(response.getEntity());
        } finally {
            response.close();
        }
    } finally {
        httpclient.close();
    }
}