net.livesite.http
Class BinaryPost

java.lang.Object
  extended by net.livesite.http.BinaryPost
All Implemented Interfaces:
Runnable

public class BinaryPost
extends Object
implements Runnable

Submits a straight-up binary post. Synopsis:

  BinaryPost post = new BinaryPost( "http://localhost/test.cgi" );
  post.setHeader( "param_name", "param_value" );
  post.setContent( binaryInputStream );
  post.run();
 

Author:
Ryan Gies

Constructor Summary
BinaryPost()
          Construct an empty class.
BinaryPost(String post_url)
          Constructs this class.
 
Method Summary
 void run()
          run - Make the connection and write the data.
 void setContent(InputStream inStream)
          setContent - The body of the post.
 void setHeader(String name, String value)
          Set HTTP headers (act as parameters).
 void setHeaders(String headerString)
          Set HTTP headers, given a header string.
 void setLocation(String post_url)
          setLocation - Set the action argument of the form (submit location).
protected  void writeContent(DataOutputStream out)
          Write byte data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryPost

public BinaryPost()
Construct an empty class.


BinaryPost

public BinaryPost(String post_url)
Constructs this class.

Parameters:
post_url - String Where to post
Method Detail

setLocation

public void setLocation(String post_url)
setLocation - Set the action argument of the form (submit location).

Parameters:
post_url - String Where to post

setHeader

public void setHeader(String name,
                      String value)
               throws Exception
Set HTTP headers (act as parameters).

Parameters:
name - String
value - String
Throws:
Exception

setHeaders

public void setHeaders(String headerString)
                throws Exception
Set HTTP headers, given a header string. Example string: 'key1: val1\nkey2: val2' setLocation must be called first!

Parameters:
headerString - colon and newline delimited string
Throws:
Exception - when the headerString is not formatted correctly

setContent

public void setContent(InputStream inStream)
                throws Exception
setContent - The body of the post.

Parameters:
inStream - InputStream
Throws:
Exception

run

public void run()
run - Make the connection and write the data. All previous methods simply set the stage for this action. Satifies the Runnable interface. Implemented so that on may set up a MulitpartForm object and then let it post on a separate thread.

Specified by:
run in interface Runnable

writeContent

protected void writeContent(DataOutputStream out)
                     throws Exception
Write byte data.

Parameters:
out - DataOutputStream
Throws:
Exception