webfunds.comms
Class RawHttp

java.lang.Object
  |
  +--webfunds.utils.Debug
        |
        +--webfunds.comms.RawHttp

public class RawHttp
extends Debug

Collection of methods for doing raw access to sockets and returning HTTP stuff.


Field Summary
protected static java.lang.String CON_CLOSE
           
protected static java.lang.String CON_TYPE
           
protected static java.lang.String CONLEN
           
protected static java.lang.String end
           
protected static java.lang.String HOSTC
           
protected static java.lang.String HTTP_VERS
           
protected static java.lang.String POSTCMD
           
protected static java.lang.String TYPE_SOX2
           
protected  java.net.URL url
          The HTTP location
 
Fields inherited from class webfunds.utils.Debug
bug, debugAll, logfix
 
Constructor Summary
RawHttp(java.net.URL url, java.io.PrintWriter bug)
          Create a new RawHttp object.
 
Method Summary
static byte[] getGetData(java.lang.String page, java.lang.String whereTo)
           
static java.lang.String getLine(java.io.InputStream is)
           
 byte[] getPage()
          Send a Http request on this URL and return the reply.
 byte[] getPage(int size)
          Send a Http request on this URL and return the reply.
static byte[] getPage(java.lang.String host, int port, java.lang.String page, int size)
          Send a Http request and await the reply.
static byte[] getPostData(byte[] request, java.lang.String whereTo)
           
static byte[] getReply(byte[] buf)
          Return the message from a POST reply
static byte[] getReply(java.io.InputStream is)
          Return the message from a POST reply
static byte[] getSocket(java.lang.String host, int port, byte[] request, int size)
          Send a request and read the reply from a socket.
 
Methods inherited from class webfunds.utils.Debug
debug, debug, debug, debug, err, getDebug, logend, logmsg, logstart, logword
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

url

protected java.net.URL url
The HTTP location

end

protected static final java.lang.String end

POSTCMD

protected static final java.lang.String POSTCMD

CONLEN

protected static final java.lang.String CONLEN

HOSTC

protected static final java.lang.String HOSTC

CON_CLOSE

protected static final java.lang.String CON_CLOSE

TYPE_SOX2

protected static final java.lang.String TYPE_SOX2

CON_TYPE

protected static final java.lang.String CON_TYPE

HTTP_VERS

protected static final java.lang.String HTTP_VERS
Constructor Detail

RawHttp

public RawHttp(java.net.URL url,
               java.io.PrintWriter bug)
Create a new RawHttp object.
Parameters:
url - the http location where requests are sent
Method Detail

getSocket

public static byte[] getSocket(java.lang.String host,
                               int port,
                               byte[] request,
                               int size)
                        throws RawURLException,
                               RawConnectException
Send a request and read the reply from a socket.
Parameters:
host - is the domain to open to
request - the bytes to write to opened socket
port - is the port, 80 if <= 0
size - is the port, some default if <= 0
Returns:
the bytes read

getPage

public byte[] getPage(int size)
               throws RawReplyException,
                      RawURLException,
                      RawConnectException
Send a Http request on this URL and return the reply.
Parameters:
size - how many bytes to read back before giving in
Returns:
the reply

getPage

public byte[] getPage()
               throws RawReplyException,
                      RawURLException,
                      RawConnectException
Send a Http request on this URL and return the reply. This calls the method(size) with 1024.
Returns:
the reply

getPage

public static byte[] getPage(java.lang.String host,
                             int port,
                             java.lang.String page,
                             int size)
                      throws RawReplyException,
                             RawURLException,
                             RawConnectException
Send a Http request and await the reply.
Parameters:
host - the domain to connect to
port - the port on the domain
page - the file component to request
size - how many bytes to read back before giving in
Returns:
the reply

getLine

public static java.lang.String getLine(java.io.InputStream is)
                                throws java.io.IOException

getReply

public static byte[] getReply(byte[] buf)
                       throws RawReplyException
Return the message from a POST reply
Returns:
the reply body

getReply

public static byte[] getReply(java.io.InputStream is)
                       throws RawReplyException
Return the message from a POST reply
Returns:
the reply body

getPostData

public static byte[] getPostData(byte[] request,
                                 java.lang.String whereTo)

getGetData

public static byte[] getGetData(java.lang.String page,
                                java.lang.String whereTo)