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  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Fonctions  · 

QHttpHeader Class Reference
[network module]

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

#include <qhttp.h>

Inherited by QHttpResponseHeader and QHttpRequestHeader.

List of all member functions.

Public Members


Detailed Description

The QHttpHeader class contains header information for HTTP.

In most cases you should use the more specialized derivatives of this class, QHttpResponseHeader and QHttpRequestHeader, rather than directly using QHttpHeader.

QHttpHeader 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 QHttpRequestHeader, QHttpResponseHeader, and Input/Output and Networking.


Member Function Documentation

QHttpHeader::QHttpHeader ()

Constructs an empty HTTP header.

QHttpHeader::QHttpHeader ( const QHttpHeader & header )

Constructs a copy of header.

QHttpHeader::QHttpHeader ( 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.

QHttpHeader::~QHttpHeader () [virtual]

Destructor.

uint QHttpHeader::contentLength () const

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

See also setContentLength() and hasContentLength().

QString QHttpHeader::contentType () const

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

See also setContentType() and hasContentType().

bool QHttpHeader::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 QHttpHeader::hasContentType () const

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

See also contentType() and setContentType().

bool QHttpHeader::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 QHttpHeader::isValid () const

Returns TRUE if the HTTP header is valid; otherwise returns FALSE.

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

QStringList QHttpHeader::keys () const

Returns a list of the keys in the HTTP header.

See also hasKey().

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

Returns the major protocol-version of the HTTP header.

Reimplemented in QHttpResponseHeader and QHttpRequestHeader.

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

Returns the minor protocol-version of the HTTP header.

Reimplemented in QHttpResponseHeader and QHttpRequestHeader.

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

Assigns h and returns a reference to this http header.

void QHttpHeader::removeValue ( const QString & key )

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

See also value() and setValue().

void QHttpHeader::setContentLength ( int len )

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

See also contentLength() and hasContentLength().

void QHttpHeader::setContentType ( const QString & type )

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

See also contentType() and hasContentType().

Example: network/archivesearch/archivedialog.ui.h.

void QHttpHeader::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().

Example: network/archivesearch/archivedialog.ui.h.

QString QHttpHeader::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 QHttpHeader::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().


This file is part of the Qt toolkit. Copyright © 1995-2005 Trolltech. All Rights Reserved.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 94
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 42
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 6
Page suivante

Le Qt Developer Network au hasard

Logo

Livre blanc de l'outillage de Qt Quick

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

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 3.3
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