Class prominence.io.PostOutputStream
All Packages Class Hierarchy This Package Previous Next Index
Class prominence.io.PostOutputStream
java.lang.Object
|
+----java.io.OutputStream
|
+----java.io.FilterOutputStream
|
+----prominence.io.PostOutputStream
- public class PostOutputStream
- extends FilterOutputStream
An OutputStream interface to a CGI POST operation.
Usage:
Create a PostOutputStream with a target URL.
Write data to this stream through the standard streams
interface; some additional writing methods are supplied.
Call post() to perform the CGI POST
operation; this method returns an InputStream to
read the server's response.
- See Also:
- URL
-
byteO
- A buffer for the data to be posted.
-
type
- The data content-type.
-
url
- The target URL.
-
PostOutputStream(URL)
- Creates a new PostOutputStream with the specified
target URL and the default content-type
"application/x-www-form-urlencoded".
-
PostOutputStream(URL, String)
- Creates a new PostOutputStream with the specified
target URL and the specified content-type.
-
encode(char)
- Returns the URL-encoded String corresponding to the
char parameter.
-
encode(String)
- Returns the URL-encoded form of the String parameter.
-
post()
- Performs a CGI POST of the buffered data, prefixed by
Content-Type and Content-Length headers, and
returns an InputStream from which the complete server
response can be read.
-
writeBytes(String)
- Writes a String as a sequence of bytes by stripping
the high-byte from each character.
-
writeTag(String, String)
- Writes a tag-value pair in URL-encoded form.
-
writeTags(Hashtable)
- Write the contents of a Hashtable as a sequence of
tag-value pairs.
byteO
protected ByteArrayOutputStream byteO
- A buffer for the data to be posted.
url
protected URL url
- The target URL.
type
protected String type
- The data content-type.
PostOutputStream
public PostOutputStream(URL url)
- Creates a new PostOutputStream with the specified
target URL and the default content-type
"application/x-www-form-urlencoded".
- Parameters:
- url - The URL to which the data should be posted
PostOutputStream
public PostOutputStream(URL url,
String type)
- Creates a new PostOutputStream with the specified
target URL and the specified content-type.
- Parameters:
- url - The URL to which the data should be posted
- type - The data content-type
writeBytes
public void writeBytes(String s) throws IOException
- Writes a String as a sequence of bytes by stripping
the high-byte from each character.
- Parameters:
- s - The String to be written
- Throws: IOException
- Occurs if there is a problem writing the data.
writeTag
public void writeTag(String tag,
String value) throws IOException
- Writes a tag-value pair in URL-encoded form.
If data has already been written to the stream, a separating
'&' is written. The URL-encoded tag name is then
written, followed by '=', followed by the URL-encoded value.
- Parameters:
- tag - The tag name
- value - The tag value
- Throws: IOException
- Occurs if there is a problem writing the data.
encode
public String encode(String s)
- Returns the URL-encoded form of the String parameter.
- Parameters:
- s - The String to be URL-encoded
- Returns:
- The URL-encoded String
encode
public String encode(char c)
- Returns the URL-encoded String corresponding to the
char parameter.
URL-encoding replaces all non-ASCII characters, and the
characters ' ', '+', '&',
'=', '%', '/', and '~'
with the corresponding escape sequence "%xx"
where xx is the hexadecimal value of the
character.
- Parameters:
- c - The char to be URL-encoded
- Returns:
- The URL-encoded String
writeTags
public void writeTags(Hashtable h) throws IOException
- Write the contents of a Hashtable as a sequence of
tag-value pairs.
- Parameters:
- h - The Hashtable of tag-value pairs.
post
public InputStream post() throws IOException
- Performs a CGI POST of the buffered data, prefixed by
Content-Type and Content-Length headers, and
returns an InputStream from which the complete server
response can be read.
- Returns:
- An InputStream from which the complete server
response can be read.
- Throws: IOException
- Occurs if there was a problem connecting
to the server or writing the POST request.
All Packages Class Hierarchy This Package Previous Next Index