Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

Q3HttpHeader Class Reference

The Q3HttpHeader class contains header information for HTTP. More...

 #include <Q3HttpHeader>

This class is part of the Qt 3 support library. It is provided to keep old source code working. We strongly advise against using it in new code. See Porting to Qt 4 for more information.

Inherited by: Q3HttpRequestHeader and Q3HttpResponseHeader.

Public Functions

Q3HttpHeader ()
Q3HttpHeader ( const Q3HttpHeader & header )
Q3HttpHeader ( const QString & str )
virtual ~Q3HttpHeader ()
uint contentLength () const
QString contentType () const
bool hasContentLength () const
bool hasContentType () const
bool hasKey ( const QString & key ) const
bool isValid () const
QStringList keys () const
virtual int majorVersion () const = 0
virtual int minorVersion () const = 0
void removeValue ( const QString & key )
void setContentLength ( int len )
void setContentType ( const QString & type )
void setValue ( const QString & key, const QString & value )
virtual QString toString () const
QString value ( const QString & key ) const
Q3HttpHeader & operator= ( const Q3HttpHeader & h )

Detailed Description

The Q3HttpHeader class contains header information for HTTP.

In most cases you should use the more specialized derivatives of this class, Q3HttpResponseHeader and Q3HttpRequestHeader, rather than directly using Q3HttpHeader.

Q3HttpHeader provides the HTTP header fields. A HTTP header field consists of a name followed by a colon, a single space, and the field value. (See RFC 1945.) Field names are case-insensitive. A typical header field looks like this:

 content-type: text/html

In the API the header field name is called the "key" and the content is called the "value". You can get and set a header field's value by using its key with value() and setValue(), e.g.

 header.setValue( "content-type", "text/html" );
 QString contentType = header.value( "content-type" );

Some fields are so common that getters and setters are provided for them as a convenient alternative to using value() and setValue(), e.g. contentLength() and contentType(), setContentLength() and setContentType().

Each header key has a single value associated with it. If you set the value for a key which already exists the previous value will be discarded.

See also Q3HttpRequestHeader and Q3HttpResponseHeader.

Member Function Documentation

Q3HttpHeader::Q3HttpHeader ()

Constructs an empty HTTP header.

Q3HttpHeader::Q3HttpHeader ( const Q3HttpHeader & header )

Constructs a copy of header.

Q3HttpHeader::Q3HttpHeader ( const QString & str )

Constructs a HTTP header for str.

This constructor parses the string str for header fields and adds this information. The str should consist of one or more "\r\n" delimited lines; each of these lines should have the format key, colon, space, value.

Q3HttpHeader::~Q3HttpHeader () [virtual]

Destructor.

uint Q3HttpHeader::contentLength () const

Returns the value of the special HTTP header field content-length.

See also setContentLength() and hasContentLength().

QString Q3HttpHeader::contentType () const

Returns the value of the special HTTP header field content-type.

See also setContentType() and hasContentType().

bool Q3HttpHeader::hasContentLength () const

Returns true if the header has an entry for the special HTTP header field content-length; otherwise returns false.

See also contentLength() and setContentLength().

bool Q3HttpHeader::hasContentType () const

Returns true if the header has an entry for the special HTTP header field content-type; otherwise returns false.

See also contentType() and setContentType().

bool Q3HttpHeader::hasKey ( const QString & key ) const

Returns true if the HTTP header has an entry with the given key; otherwise returns false.

See also value(), setValue(), and keys().

bool Q3HttpHeader::isValid () const

Returns true if the HTTP header is valid; otherwise returns false.

A Q3HttpHeader is invalid if it was created by parsing a malformed string.

QStringList Q3HttpHeader::keys () const

Returns a list of the keys in the HTTP header.

See also hasKey().

int Q3HttpHeader::majorVersion () const [pure virtual]

Returns the major protocol-version of the HTTP header.

int Q3HttpHeader::minorVersion () const [pure virtual]

Returns the minor protocol-version of the HTTP header.

void Q3HttpHeader::removeValue ( const QString & key )

Removes the entry with the key key from the HTTP header.

See also value() and setValue().

void Q3HttpHeader::setContentLength ( int len )

Sets the value of the special HTTP header field content-length to len.

See also contentLength() and hasContentLength().

void Q3HttpHeader::setContentType ( const QString & type )

Sets the value of the special HTTP header field content-type to type.

See also contentType() and hasContentType().

void Q3HttpHeader::setValue ( const QString & key, const QString & value )

Sets the value of the entry with the key to value.

If no entry with key exists, a new entry with the given key and value is created. If an entry with the key already exists, its value is discarded and replaced with the given value.

See also value(), hasKey(), and removeValue().

QString Q3HttpHeader::toString () const [virtual]

Returns a string representation of the HTTP header.

The string is suitable for use by the constructor that takes a QString. It consists of lines with the format: key, colon, space, value, "\r\n".

QString Q3HttpHeader::value ( const QString & key ) const

Returns the value for the entry with the given key. If no entry has this key, an empty string is returned.

See also setValue(), removeValue(), hasKey(), and keys().

Q3HttpHeader & Q3HttpHeader::operator= ( const Q3HttpHeader & h )

Assigns h and returns a reference to this http header.

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.8
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web