net.noderunner.http
Class MessageHeader

java.lang.Object
  extended by net.noderunner.http.MessageHeader

public class MessageHeader
extends java.lang.Object

This is an immutable implementation of the MessageHeader interface.


Field Summary
static java.lang.String FN_CONNECTION
          Field name for the connection header.
static java.lang.String FN_CONTENT_LENGTH
          Field name for the content-length header.
static java.lang.String FN_CONTENT_TYPE
          Field name for the content-type header.
static java.lang.String FN_HOST
          Field name for the host header.
static java.lang.String FN_LOCATION
          Field name for the location header.
static java.lang.String FN_REFERER
          Field name for the referer header.
static java.lang.String FN_SERVER
          Field name for the server header.
static java.lang.String FN_TRANSFER_ENCODING
          Field name for the user agent header.
static java.lang.String FN_USER_AGENT
          Field name for the user agent header.
static MessageHeader MH_CONNECTION_CLOSE
          Use this MessageHeader for indicating connection close.
static MessageHeader MH_CONNECTION_KEEP_ALIVE
          Use this MessageHeader for indicating a keep-alive connection.
static MessageHeader MH_TRANSFER_ENCODING_CHUNKED
          Use this MessageHeader for sending chunked data.
static MessageHeader MH_URL_ENCODED
          Use this MessageHeader for indicating a URL encoded content type.
static MessageHeader MH_USER_AGENT
          Default user agent string for this library.
 
Constructor Summary
MessageHeader(java.lang.String fieldName, java.lang.String fieldValue)
          Initialize using a field-name and field-value.
 
Method Summary
 boolean equals(java.lang.Object other)
           
 java.lang.String getFieldContent()
          Returns the value of this header.
 java.lang.String getFieldName()
          Returns the name of the header, which for consistency is in lower-case form.
 int hashCode()
          Returns the hashcode.
static MessageHeader makeHostHeader(java.net.URL url)
          Returns a new Host header, appropriate to the given URL.
static MessageHeader parse(java.lang.String messageHeader)
          Parse using a message-header string.
 java.lang.String toString()
          Should return this MessageHeader as:
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FN_HOST

public static final java.lang.String FN_HOST
Field name for the host header.

See Also:
Constant Field Values

FN_CONNECTION

public static final java.lang.String FN_CONNECTION
Field name for the connection header.

See Also:
Constant Field Values

FN_CONTENT_LENGTH

public static final java.lang.String FN_CONTENT_LENGTH
Field name for the content-length header.

See Also:
Constant Field Values

FN_CONTENT_TYPE

public static final java.lang.String FN_CONTENT_TYPE
Field name for the content-type header.

See Also:
Constant Field Values

FN_LOCATION

public static final java.lang.String FN_LOCATION
Field name for the location header. Typically used in redirects.

See Also:
Constant Field Values

FN_REFERER

public static final java.lang.String FN_REFERER
Field name for the referer header.

See Also:
Constant Field Values

FN_TRANSFER_ENCODING

public static final java.lang.String FN_TRANSFER_ENCODING
Field name for the user agent header.

See Also:
Constant Field Values

FN_USER_AGENT

public static final java.lang.String FN_USER_AGENT
Field name for the user agent header.

See Also:
Constant Field Values

FN_SERVER

public static final java.lang.String FN_SERVER
Field name for the server header.

See Also:
Constant Field Values

MH_TRANSFER_ENCODING_CHUNKED

public static final MessageHeader MH_TRANSFER_ENCODING_CHUNKED
Use this MessageHeader for sending chunked data.


MH_CONNECTION_KEEP_ALIVE

public static final MessageHeader MH_CONNECTION_KEEP_ALIVE
Use this MessageHeader for indicating a keep-alive connection.


MH_CONNECTION_CLOSE

public static final MessageHeader MH_CONNECTION_CLOSE
Use this MessageHeader for indicating connection close.


MH_URL_ENCODED

public static final MessageHeader MH_URL_ENCODED
Use this MessageHeader for indicating a URL encoded content type.


MH_USER_AGENT

public static final MessageHeader MH_USER_AGENT
Default user agent string for this library.

Constructor Detail

MessageHeader

public MessageHeader(java.lang.String fieldName,
                     java.lang.String fieldValue)
Initialize using a field-name and field-value.

Method Detail

parse

public static MessageHeader parse(java.lang.String messageHeader)
                           throws HttpException
Parse using a message-header string.

Throws:
HttpException - if invalid HTTP message header data was used in initialization

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

getFieldName

public java.lang.String getFieldName()
Returns the name of the header, which for consistency is in lower-case form.


getFieldContent

public java.lang.String getFieldContent()
Returns the value of this header. In terms of RFC 2616, this is the header's field-content, which excludes trailing and following white-space.


hashCode

public int hashCode()
Returns the hashcode.

Overrides:
hashCode in class java.lang.Object

makeHostHeader

public static MessageHeader makeHostHeader(java.net.URL url)
Returns a new Host header, appropriate to the given URL.


toString

public java.lang.String toString()
Should return this MessageHeader as:
 getFieldName() + ':' + getFieldContent();
 

Overrides:
toString in class java.lang.Object


Copyright © 2009. All Rights Reserved.