php.java.bridge.http
Class HeaderParser

java.lang.Object
  extended by php.java.bridge.http.HeaderParser
Direct Known Subclasses:
SimpleHeaderParser

public abstract class HeaderParser
extends java.lang.Object

A procedure class which can be used to capture the HTTP header strings. Example:
Util.parseBody(buf, natIn, out, new Util.HeaderParser() {protected void parseHeader(String header) {System.out.println(header);}});

Author:
jostb
See Also:
parseBody(byte[], InputStream, OutputStreamFactory, HeaderParser)

Field Summary
static HeaderParser DEFAULT_HEADER_PARSER
          The default CGI header parser.
 
Constructor Summary
HeaderParser()
           
 
Method Summary
abstract  void addHeader(java.lang.String key, java.lang.String val)
          Add a header
static void parseBody(byte[] buf, java.io.InputStream natIn, OutputStreamFactory out, HeaderParser parser)
          Discards all header fields from a HTTP connection and write the body to the OutputStream
abstract  void parseHeader(java.lang.String header)
          Parse a header
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_HEADER_PARSER

public static final HeaderParser DEFAULT_HEADER_PARSER
The default CGI header parser. The default implementation discards everything.

Constructor Detail

HeaderParser

public HeaderParser()
Method Detail

parseHeader

public abstract void parseHeader(java.lang.String header)
Parse a header

Parameters:
header - The header string to parse

addHeader

public abstract void addHeader(java.lang.String key,
                               java.lang.String val)
Add a header

Parameters:
key - the key
val - the value

parseBody

public static void parseBody(byte[] buf,
                             java.io.InputStream natIn,
                             OutputStreamFactory out,
                             HeaderParser parser)
                      throws java.io.UnsupportedEncodingException,
                             java.io.IOException
Discards all header fields from a HTTP connection and write the body to the OutputStream

Parameters:
buf - A buffer, for example new byte[BUF_SIZE]
natIn - The InputStream
out - The OutputStream
parser - The header parser
Throws:
java.io.UnsupportedEncodingException
java.io.IOException