tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 
 Tools and Libs > Commons Http Client > How to get supported schemas

How to get supported schemas 

Commons Http Client is a HTTP agent implementation in java supporting client-side authentication, HTTP state management and HTTP connection management. This requires the libraries httpclient-4.1.2.jar, httpcore-4.1.2.jar, httpmime-4.1.2.jar, httpclient-cache-4.1.2.jar, commons-codec.jar and commons-logging-1.1.1.jar to be in classpath. The following example shows getting the default schemas supported by Commons Http Client.

File Name  :  
com/bethecoder/tutorials/commons_httpclient/SupportedSchemesTest.java 
Author  :  Sudhakar KV
Email  :  kvenkatasudhakar@gmail.com
   
package com.bethecoder.tutorials.commons_httpclient;

import org.apache.http.client.HttpClient;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.impl.client.DefaultHttpClient;

public class SupportedSchemesTest {

  /**
   @param args
   */
  public static void main(String[] args) {
    HttpClient httpclient = new DefaultHttpClient();
    SchemeRegistry schemeRegistry = httpclient.getConnectionManager().getSchemeRegistry();
    System.out.println("Registered Schemes : " + schemeRegistry.getSchemeNames());
    
    Scheme httpScheme = schemeRegistry.get("http");
    System.out.println("Scheme Name : " + httpScheme.getName());
    System.out.println("Default Port : " + httpScheme.getDefaultPort());
    
    Scheme httpsScheme = schemeRegistry.get("https");
    System.out.println("Scheme Name : " + httpsScheme.getName());
    System.out.println("Default Port : " + httpsScheme.getDefaultPort());
  }

}
   

It gives the following output,
Registered Schemes : [https, http]

Scheme Name : http
Default Port : 80

Scheme Name : https
Default Port : 443


                    Print

   



Books Recommendation

 
 
bl  br