net.sf.bvalid.util
Class HttpInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by net.sf.bvalid.util.HttpInputStream
All Implemented Interfaces:
java.io.Closeable

public class HttpInputStream
extends java.io.InputStream

An InputStream from an HttpMethod. When this InputStream is close()d, the underlying http connection is automatically released.


Constructor Summary
HttpInputStream(org.apache.commons.httpclient.HttpClient client, org.apache.commons.httpclient.HttpMethod method, java.lang.String url)
           
 
Method Summary
 int available()
           
 void close()
          Release the underlying http connection and close the InputStream.
 void finalize()
          Automatically close on garbage collection.
 java.lang.String getMethodName()
          Get the http method name (GET or POST).
 org.apache.commons.httpclient.Header getResponseHeader(java.lang.String name)
          Get a specific response header.
 org.apache.commons.httpclient.Header[] getResponseHeaders()
          Get all response headers.
 java.lang.String getResponseHeaderValue(java.lang.String name, java.lang.String defaultValue)
          Get a response header value string, or defaultValue if the header is undefined or empty.
 int getStatusCode()
          Get the http status code.
 java.lang.String getStatusText()
          Get the "reason phrase" associated with the status code.
 java.lang.String getURL()
          Get the original URL of the http request this InputStream is based on.
 void mark(int readlimit)
           
 boolean markSupported()
           
 int read()
           
 int read(byte[] b)
           
 int read(byte[] b, int off, int len)
           
 void reset()
           
 long skip(long n)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpInputStream

public HttpInputStream(org.apache.commons.httpclient.HttpClient client,
                       org.apache.commons.httpclient.HttpMethod method,
                       java.lang.String url)
                throws java.io.IOException
Throws:
java.io.IOException
Method Detail

getMethodName

public java.lang.String getMethodName()
Get the http method name (GET or POST).


getURL

public java.lang.String getURL()
Get the original URL of the http request this InputStream is based on.


getStatusCode

public int getStatusCode()
Get the http status code.


getStatusText

public java.lang.String getStatusText()
Get the "reason phrase" associated with the status code.


getResponseHeader

public org.apache.commons.httpclient.Header getResponseHeader(java.lang.String name)
Get a specific response header.


getResponseHeaderValue

public java.lang.String getResponseHeaderValue(java.lang.String name,
                                               java.lang.String defaultValue)
Get a response header value string, or defaultValue if the header is undefined or empty.


getResponseHeaders

public org.apache.commons.httpclient.Header[] getResponseHeaders()
Get all response headers.


finalize

public void finalize()
Automatically close on garbage collection.

Overrides:
finalize in class java.lang.Object

read

public int read()
         throws java.io.IOException
Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] b)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException

skip

public long skip(long n)
          throws java.io.IOException
Overrides:
skip in class java.io.InputStream
Throws:
java.io.IOException

available

public int available()
              throws java.io.IOException
Overrides:
available in class java.io.InputStream
Throws:
java.io.IOException

mark

public void mark(int readlimit)
Overrides:
mark in class java.io.InputStream

reset

public void reset()
           throws java.io.IOException
Overrides:
reset in class java.io.InputStream
Throws:
java.io.IOException

markSupported

public boolean markSupported()
Overrides:
markSupported in class java.io.InputStream

close

public void close()
           throws java.io.IOException
Release the underlying http connection and close the InputStream.

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException