Gnutella::Handshaking::ResponseHeader Class Reference

#include <ResponseHeader.h> [code]

Inherits Http::Header.

Inheritance diagram for Gnutella::Handshaking::ResponseHeader:

Inheritance graph
[legend]
Collaboration diagram for Gnutella::Handshaking::ResponseHeader:

Collaboration graph
[legend]
List of all members.

Detailed Description

Encapsulates a Gnutella CONNECT response handshake header.

A typical Gnutella CONNECT handshake has the form:

    GNUTELLA/<majorVersion>.<minorVersion> <statusCode> <reasonPhrase> CRLF
    Handshake-Header1: header value 1 CRLF
    ...
    Handshake-HeaderN: header value N CRLF
    CRLF

Objects of this class are used in the HandshakeConnection class to facilitate header exchange during the handshaking phase of a Gnutella connection.

Todo:
Use a uniform notation for member variables. Decide on whether to use PrivateObject derived classes to store private data.

Definition at line 52 of file ResponseHeader.h.

Public Member Functions

 ResponseHeader ()
 ResponseHeader (const ResponseHeader &header)
 Copy constructor.
 ResponseHeader (const QString &str)
 Constructor.
 ResponseHeader (int code, const QString &phrase, int majorVer=0, int minorVer=6)
 Constructor.
ResponseHeaderoperator= (const ResponseHeader &header)
 Assignment operator.
int majorVersion () const
 Gets the protocol's major version.
int minorVersion () const
 Gets the protocol's minor version.
int statusCode () const
 Gets the response's status code.
QString reasonPhrase () const
 Gets the response's reason phrase.
QString toString () const
 Generates and returns the complete header as text.

Protected Member Functions

bool parseLine (const QString &line, int number)
 Parses a single header line.

Private Attributes

int majorVersion_
 The major version field.
int minorVersion_
 The minor version field.
int statusCode_
 The response's status code.
QString reasonPhrase_
 The response's reason phrase.


Constructor & Destructor Documentation

Gnutella::Handshaking::ResponseHeader::ResponseHeader  )  [inline]
 

Todo:
This constructor we need bacause of HandshakeConnection storing the the headers as members and not just pointers which will be initialized when required. Should we remove the default constructor and switch to pointers? The same considerations are valid also for HandshakeRequestHeader. The only difference is that we have a default constructor due to the default parameters.

Definition at line 63 of file ResponseHeader.h.

ResponseHeader::ResponseHeader const ResponseHeader header  ) 
 

Copy constructor.

Definition at line 60 of file ResponseHeader.cpp.

ResponseHeader::ResponseHeader const QString &  str  ) 
 

Constructor.

Creates and initalizes an object by parsing the str. You can get the values of the parsed header fields by calling the corresponding functions from the base class HttpHeader.

See also:
HttpHeader::fieldValue(), QHpptHeader::fieldValues()

Definition at line 37 of file ResponseHeader.cpp.

ResponseHeader::ResponseHeader int  code,
const QString &  phrase,
int  majorVersion = 0,
int  minorVersion = 6
 

Constructor.

Creates and initialzes an object with code, phrase, majorVersion and minorVersion. To set some header field values call the corresonding functions of from the base class.

See also:
HttpHeader::setFieldValue(), HttpHeader::addFieldValue(), HttpHeader::addFieldValues()

Definition at line 52 of file ResponseHeader.cpp.


Member Function Documentation

int Gnutella::Handshaking::ResponseHeader::majorVersion  )  const [inline]
 

Gets the protocol's major version.

Definition at line 71 of file ResponseHeader.h.

int Gnutella::Handshaking::ResponseHeader::minorVersion  )  const [inline]
 

Gets the protocol's minor version.

Definition at line 72 of file ResponseHeader.h.

ResponseHeader & ResponseHeader::operator= const ResponseHeader header  ) 
 

Assignment operator.

Definition at line 68 of file ResponseHeader.cpp.

bool ResponseHeader::parseLine const QString &  line,
int  number
[protected, virtual]
 

Parses a single header line.

Parses a single header line. This is a virtual function overridden here to parse just the first line of the header differently than if it were pure HTTP, but not Gnutella. The other lines are parsed by the base class implementation.

See also:
QHttpHeader::parseLine()

Reimplemented from Http::Header.

Definition at line 87 of file ResponseHeader.cpp.

QString Gnutella::Handshaking::ResponseHeader::reasonPhrase  )  const [inline]
 

Gets the response's reason phrase.

Definition at line 74 of file ResponseHeader.h.

int Gnutella::Handshaking::ResponseHeader::statusCode  )  const [inline]
 

Gets the response's status code.

Definition at line 73 of file ResponseHeader.h.

QString ResponseHeader::toString  )  const [virtual]
 

Generates and returns the complete header as text.

Returns:
A QString object containing the header.

Reimplemented from Http::Header.

Definition at line 117 of file ResponseHeader.cpp.


Member Data Documentation

int Gnutella::Handshaking::ResponseHeader::majorVersion_ [private]
 

The major version field.

Definition at line 82 of file ResponseHeader.h.

int Gnutella::Handshaking::ResponseHeader::minorVersion_ [private]
 

The minor version field.

Definition at line 83 of file ResponseHeader.h.

QString Gnutella::Handshaking::ResponseHeader::reasonPhrase_ [private]
 

The response's reason phrase.

Definition at line 85 of file ResponseHeader.h.

int Gnutella::Handshaking::ResponseHeader::statusCode_ [private]
 

The response's status code.

Definition at line 84 of file ResponseHeader.h.


The documentation for this class was generated from the following files: