com.cometway.net
Class HTTPClient

java.lang.Object
  extended by com.cometway.net.HTTPClient

public class HTTPClient
extends java.lang.Object

This class supplies the static methods for the HTTPLoader. The actual HTTP/1.0 protocol is implemented in this class.


Field Summary
static int readBufferSize
           
 
Constructor Summary
HTTPClient()
           
 
Method Summary
static java.lang.String convert(java.lang.String in)
          * This method converts a string to a POST param value encoding
static java.lang.String read(java.io.InputStream reader, int bytes, java.io.OutputStream dataOut, HTTPLoader loader)
          * This methods reads only a certain number of bytes from the InputStream then returns.
static java.lang.String read(java.io.InputStream reader, java.io.OutputStream dataOut, HTTPLoader loader)
          * This method reads from the InputStream until there is nothing left to read.
static void readHeader(java.io.InputStream in, HTTPResponse rval, HTTPLoader loader)
          * This method reads from a InputStream the response header after a request was sent to the associated BufferedWriter.
static HTTPResponse sendRequest(HTTPRequest request, java.io.InputStream in, java.io.BufferedWriter out, java.io.OutputStream dataOut, HTTPLoader loader)
           
static java.lang.String unconvert(java.lang.String in)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

readBufferSize

public static int readBufferSize
Constructor Detail

HTTPClient

public HTTPClient()
Method Detail

sendRequest

public static HTTPResponse sendRequest(HTTPRequest request,
                                       java.io.InputStream in,
                                       java.io.BufferedWriter out,
                                       java.io.OutputStream dataOut,
                                       HTTPLoader loader)
                                throws java.io.IOException
Throws:
java.io.IOException

readHeader

public static void readHeader(java.io.InputStream in,
                              HTTPResponse rval,
                              HTTPLoader loader)
                       throws java.io.IOException
* This method reads from a InputStream the response header after a request was sent to the associated BufferedWriter. Lines are read until a double newline is encountered which signifies the end of the header. Header fields and values are stored in a Hashtable which is returned. The HTTP result is stored as the key 'HTTP'. This will always be a 3 digit value stored as a String.

Throws:
java.io.IOException

read

public static java.lang.String read(java.io.InputStream reader,
                                    java.io.OutputStream dataOut,
                                    HTTPLoader loader)
                             throws java.io.IOException
* This method reads from the InputStream until there is nothing left to read. Do not use this method if the last line does not end with a newline or if the connection is going to hang, otherwise, this method will block.

Parameters:
reader - This is the InputStream to read from.
Returns:
Returns as a String the data read from the reader.
Throws:
java.io.IOException

read

public static java.lang.String read(java.io.InputStream reader,
                                    int bytes,
                                    java.io.OutputStream dataOut,
                                    HTTPLoader loader)
                             throws java.io.IOException
* This methods reads only a certain number of bytes from the InputStream then returns.

Parameters:
reader - This is the InputStream to read from.
bytes - This is the number of bytes (Characters) to read.
Returns:
Returns as a String the data read from the reader.
Throws:
java.io.IOException

convert

public static java.lang.String convert(java.lang.String in)
* This method converts a string to a POST param value encoding


unconvert

public static java.lang.String unconvert(java.lang.String in)