ucar.nc2.util.net
Class HttpClientManager

java.lang.Object
  extended by ucar.nc2.util.net.HttpClientManager

public class HttpClientManager
extends Object

Convenience routines that wrap HTTPSession.

Author:
caron

Constructor Summary
HttpClientManager()
           
 
Method Summary
static long appendUrlContentsToFile(HTTPSession session, String urlString, File file, long start, long end)
           
static void clearState()
           
static void copyUrlContentsToFile(HTTPSession session, String urlString, File file)
           
static String getContentAsString(HTTPSession session, String urlString)
          Get the content from a url.
static String getUrlContentsAsString(HTTPSession session, String urlString, int maxKbytes)
           
static void init(org.apache.commons.httpclient.auth.CredentialsProvider provider, String userAgent)
          initialize the HttpClient layer.
static int putContent(String urlString, String content)
          Put content to a url, using HTTP PUT.
static void showHttpRequestInfo(Formatter f, org.apache.commons.httpclient.HttpMethodBase m)
           
static void showHttpResponseInfo(Formatter f, org.apache.commons.httpclient.HttpMethodBase m)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpClientManager

public HttpClientManager()
Method Detail

init

public static void init(org.apache.commons.httpclient.auth.CredentialsProvider provider,
                        String userAgent)
initialize the HttpClient layer.

Parameters:
provider - CredentialsProvider.
userAgent - Content of User-Agent header, may be null

clearState

public static void clearState()

getContentAsString

public static String getContentAsString(HTTPSession session,
                                        String urlString)
                                 throws IOException
Get the content from a url. For large returns, its better to use getResponseAsStream.

Parameters:
session - use this session, if null, create a new one
urlString - url as a String
Returns:
contents of url as a String
Throws:
IOException - on error

putContent

public static int putContent(String urlString,
                             String content)
                      throws IOException
Put content to a url, using HTTP PUT. Handles one level of 302 redirection.

Parameters:
urlString - url as a String
content - PUT this content at the given url.
Returns:
the HTTP status return code
Throws:
IOException - on error

getUrlContentsAsString

public static String getUrlContentsAsString(HTTPSession session,
                                            String urlString,
                                            int maxKbytes)

copyUrlContentsToFile

public static void copyUrlContentsToFile(HTTPSession session,
                                         String urlString,
                                         File file)
                                  throws HTTPException
Throws:
HTTPException

appendUrlContentsToFile

public static long appendUrlContentsToFile(HTTPSession session,
                                           String urlString,
                                           File file,
                                           long start,
                                           long end)
                                    throws HTTPException
Throws:
HTTPException

showHttpRequestInfo

public static void showHttpRequestInfo(Formatter f,
                                       org.apache.commons.httpclient.HttpMethodBase m)

showHttpResponseInfo

public static void showHttpResponseInfo(Formatter f,
                                        org.apache.commons.httpclient.HttpMethodBase m)


Copyright © 1999-2011 UCAR/Unidata. All Rights Reserved.