/* $Id: SampleHttpClient.java 125 2011-03-09 09:49:51Z ohura $ */
package webdav.ssl;

import javax.net.ssl.HttpsURLConnection;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.protocol.Protocol;
import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;

public class SampleHttpClient {

	private static String PATH = "/groupware/login/login.go?AD=init";

	private static String HOST = "sp.northgrid.co.jp";

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			String responseBody;
			HttpClient client = new HttpClient();
			Protocol.registerProtocol("https", new Protocol("https",
	                new MySSLSocketFactory(), 443));
			HttpMethod method = new GetMethod("https://sp.northgrid.co.jp" + PATH);
			int statusCode = client.executeMethod(method);
			System.out.println("statusCode = " + statusCode);
			responseBody = method.getResponseBodyAsString();
			System.out.println(responseBody);

			method.releaseConnection();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
