Cross-Platform C++

ot::net
class MimeHeaderSequence

#include "ot/net/MimeHeaderSequence.h"

ot::ManagedObject Class that encapsulates a sequence of MIME-type headers. MIME (Multipurpose Internet Mail Extensions) headers are used by HTTP/1.0 and above as well as other Internet protocols to provide meta information about the data transferred and to modify requests and responses.

The format of a MIME header is:-

    header   =    name ":" <SP> value <CRLF>
A sequence of MIME headers is terminated by a trailing <CRLF>.

See also:
MimeHeaderParser



Method Summary
 void clear()
         Removes all headers from this sequence.
 bool containsHeader(const String& key) const
         Determines if the the specified header name exists within this sequence.
 int findHeader(const String& key) const
         Locates the index position for the first instance of the specified header name.
 String getHeader(const String& key) const
         Returns the value for the specified header name, or the empty string if the requested header is not present within this sequence.
 String getHeader(size_t index) const
         Returns the value for the specified header, or the empty string if the specified index is outside of the bounds of this sequence.
 String getHeaderKey(size_t index) const
         Returns the name for the specified header, or the empty string if the specified index is outside of the bounds of this sequence.
 void insertHeader(const String& key, const String& value)
         Adds the specified header to the end of this sequence.
 void removeAllHeaders(const String& key)
         Removes all headers with the specified name from this sequence.
 void setHeaderExclusive(const String& key, const String& value)
         Sets the value for a header field, overwriting any existing headers with the specified name.
 bool setHeaderIfAbsent(const String& key, const String& value)
         Sets the value for a header field only when there is not an existing headers within this sequence with the specified name.
 size_t size() const
         Returns the number of elements in this sequence.
 void writeHeaders(Writer* pWriter)
         Writes all the headers to the supplied Writer.

Methods inherited from class ot::ManagedObject
addRef(), getRefCount(), onFinalRelease(), operator=(const ManagedObject&), release()

Method Detail

clear

void clear()
Removes all headers from this sequence.


containsHeader

bool containsHeader(const String& key) const
Determines if the the specified header name exists within this sequence.

Parameters:
key - the name of the header.
Returns:
true if the header exists; false otherwise.

findHeader

int findHeader(const String& key) const
Locates the index position for the first instance of the specified header name.

Parameters:
key - the name of the header to find.
Returns:
a zero-based index of the header or -1 if the header is not present within this sequence.

getHeader

String getHeader(const String& key) const
Returns the value for the specified header name, or the empty string if the requested header is not present within this sequence.

Parameters:
key - the name of the header.
Returns:
the value of the header or an empty string.

getHeader

String getHeader(size_t index) const
Returns the value for the specified header, or the empty string if the specified index is outside of the bounds of this sequence.

Parameters:
index - the zero-based index of the header.
Returns:
the value of the header or an empty string.

getHeaderKey

String getHeaderKey(size_t index) const
Returns the name for the specified header, or the empty string if the specified index is outside of the bounds of this sequence.

Parameters:
index - the zero-based index of the header.
Returns:
the name of the header or an empty string.

insertHeader

void insertHeader(const String& key,
                  const String& value)
Adds the specified header to the end of this sequence.

Parameters:
key - the name of the header.
value - the value to assign to the header.

removeAllHeaders

void removeAllHeaders(const String& key)
Removes all headers with the specified name from this sequence.

Parameters:
key - the name of the header(s) to remove.

setHeaderExclusive

void setHeaderExclusive(const String& key,
                        const String& value)
Sets the value for a header field, overwriting any existing headers with the specified name.

Parameters:
key - the name of the header.
value - the value to assign to the header.

setHeaderIfAbsent

bool setHeaderIfAbsent(const String& key,
                       const String& value)
Sets the value for a header field only when there is not an existing headers within this sequence with the specified name.

Parameters:
key - the name of the header. @value the value to assign to the header.
Returns:
true if the header did not already exist and has been set; false otherwise.

size

size_t size() const
Returns the number of elements in this sequence.


writeHeaders

void writeHeaders(Writer* pWriter)
Writes all the headers to the supplied Writer.

Parameters:
pWriter - the Writer to use.
Exceptions:
NullPointerException - if pWriter is null.
IOException - if an I/O error occurs.


Cross-Platform C++

Found a bug or missing feature? Please email us at support@elcel.com

Copyright © 2000-2005 ElCel Technology   Trademark Acknowledgements