<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <!-- /tmp/qt-4.3.4-qt-1203442408707/qt-x11-opensource-src-4.3.4/src/qt3support/network/q3http.cpp --> <head> <title>Qt 4.3: Q3HttpHeader Class Reference</title> <link href="classic.css" rel="stylesheet" type="text/css" /> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></a></td> <td width="1"> </td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="mainclasses.html"><font color="#004faf">Main Classes</font></a> · <a href="groups.html"><font color="#004faf">Grouped Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a> · <a href="functions.html"><font color="#004faf">Functions</font></a></td> <td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">Q3HttpHeader Class Reference<br /><sup><sup>[<a href="qt3support.html">Qt3Support</a> module]</sup></sup></h1> <p>The Q3HttpHeader class contains header information for HTTP. <a href="#details">More...</a></p> <pre> #include <Q3HttpHeader></pre><p><b>This class is part of the Qt 3 support library.</b> It is provided to keep old source code working. We strongly advise against using it in new code. See <a href="porting4.html">Porting to Qt 4</a> for more information.</p> <p><b>Note to Qt Desktop Light Edition users:</b> This class is only available in the <a href="commercialeditions.html#qt-desktop-edition">Qt Desktop Edition</a>.</p> <p>Inherited by <a href="q3httprequestheader.html">Q3HttpRequestHeader</a> and <a href="q3httpresponseheader.html">Q3HttpResponseHeader</a>.</p> <ul> <li><a href="q3httpheader-members.html">List of all members, including inherited members</a></li> </ul> <a name="public-functions"></a> <h3>Public Functions</h3> <ul> <li><div class="fn"/><b><a href="q3httpheader.html#Q3HttpHeader">Q3HttpHeader</a></b> ()</li> <li><div class="fn"/><b><a href="q3httpheader.html#Q3HttpHeader-2">Q3HttpHeader</a></b> ( const Q3HttpHeader & <i>header</i> )</li> <li><div class="fn"/><b><a href="q3httpheader.html#Q3HttpHeader-3">Q3HttpHeader</a></b> ( const QString & <i>str</i> )</li> <li><div class="fn"/>virtual <b><a href="q3httpheader.html#dtor.Q3HttpHeader">~Q3HttpHeader</a></b> ()</li> <li><div class="fn"/>uint <b><a href="q3httpheader.html#contentLength">contentLength</a></b> () const</li> <li><div class="fn"/>QString <b><a href="q3httpheader.html#contentType">contentType</a></b> () const</li> <li><div class="fn"/>bool <b><a href="q3httpheader.html#hasContentLength">hasContentLength</a></b> () const</li> <li><div class="fn"/>bool <b><a href="q3httpheader.html#hasContentType">hasContentType</a></b> () const</li> <li><div class="fn"/>bool <b><a href="q3httpheader.html#hasKey">hasKey</a></b> ( const QString & <i>key</i> ) const</li> <li><div class="fn"/>bool <b><a href="q3httpheader.html#isValid">isValid</a></b> () const</li> <li><div class="fn"/>QStringList <b><a href="q3httpheader.html#keys">keys</a></b> () const</li> <li><div class="fn"/>virtual int <b><a href="q3httpheader.html#majorVersion">majorVersion</a></b> () const = 0</li> <li><div class="fn"/>virtual int <b><a href="q3httpheader.html#minorVersion">minorVersion</a></b> () const = 0</li> <li><div class="fn"/>void <b><a href="q3httpheader.html#removeValue">removeValue</a></b> ( const QString & <i>key</i> )</li> <li><div class="fn"/>void <b><a href="q3httpheader.html#setContentLength">setContentLength</a></b> ( int <i>len</i> )</li> <li><div class="fn"/>void <b><a href="q3httpheader.html#setContentType">setContentType</a></b> ( const QString & <i>type</i> )</li> <li><div class="fn"/>void <b><a href="q3httpheader.html#setValue">setValue</a></b> ( const QString & <i>key</i>, const QString & <i>value</i> )</li> <li><div class="fn"/>virtual QString <b><a href="q3httpheader.html#toString">toString</a></b> () const</li> <li><div class="fn"/>QString <b><a href="q3httpheader.html#value">value</a></b> ( const QString & <i>key</i> ) const</li> <li><div class="fn"/>Q3HttpHeader & <b><a href="q3httpheader.html#operator-eq">operator=</a></b> ( const Q3HttpHeader & <i>h</i> )</li> </ul> <a name="details"></a> <hr /> <h2>Detailed Description</h2> <p>The Q3HttpHeader class contains header information for HTTP.</p> <p>In most cases you should use the more specialized derivatives of this class, <a href="q3httpresponseheader.html">Q3HttpResponseHeader</a> and <a href="q3httprequestheader.html">Q3HttpRequestHeader</a>, rather than directly using Q3HttpHeader.</p> <p>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:</p> <pre> content-type: text/html</pre> <p>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 <a href="q3httpheader.html#value">value</a>() and <a href="q3httpheader.html#setValue">setValue</a>(), e.g.</p> <pre> header.setValue( "content-type", "text/html" ); QString contentType = header.value( "content-type" );</pre> <p>Some fields are so common that getters and setters are provided for them as a convenient alternative to using <a href="q3httpheader.html#value">value</a>() and <a href="q3httpheader.html#setValue">setValue</a>(), e.g. <a href="q3httpheader.html#contentLength">contentLength</a>() and <a href="q3httpheader.html#contentType">contentType</a>(), <a href="q3httpheader.html#setContentLength">setContentLength</a>() and <a href="q3httpheader.html#setContentType">setContentType</a>().</p> <p>Each header key has a <i>single</i> value associated with it. If you set the value for a key which already exists the previous value will be discarded.</p> <p>See also <a href="q3httprequestheader.html">Q3HttpRequestHeader</a> and <a href="q3httpresponseheader.html">Q3HttpResponseHeader</a>.</p> <hr /> <h2>Member Function Documentation</h2> <h3 class="fn"><a name="Q3HttpHeader"></a>Q3HttpHeader::Q3HttpHeader ()</h3> <p>Constructs an empty HTTP header.</p> <h3 class="fn"><a name="Q3HttpHeader-2"></a>Q3HttpHeader::Q3HttpHeader ( const Q3HttpHeader & <i>header</i> )</h3> <p>Constructs a copy of <i>header</i>.</p> <h3 class="fn"><a name="Q3HttpHeader-3"></a>Q3HttpHeader::Q3HttpHeader ( const <a href="qstring.html">QString</a> & <i>str</i> )</h3> <p>Constructs a HTTP header for <i>str</i>.</p> <p>This constructor parses the string <i>str</i> for header fields and adds this information. The <i>str</i> should consist of one or more "\r\n" delimited lines; each of these lines should have the format key, colon, space, value.</p> <h3 class="fn"><a name="dtor.Q3HttpHeader"></a>Q3HttpHeader::~Q3HttpHeader () <tt> [virtual]</tt></h3> <p>Destructor.</p> <h3 class="fn"><a name="contentLength"></a><a href="qtglobal.html#uint-typedef">uint</a> Q3HttpHeader::contentLength () const</h3> <p>Returns the value of the special HTTP header field <tt>content-length</tt>.</p> <p>See also <a href="q3httpheader.html#setContentLength">setContentLength</a>() and <a href="q3httpheader.html#hasContentLength">hasContentLength</a>().</p> <h3 class="fn"><a name="contentType"></a><a href="qstring.html">QString</a> Q3HttpHeader::contentType () const</h3> <p>Returns the value of the special HTTP header field <tt>content-type</tt>.</p> <p>See also <a href="q3httpheader.html#setContentType">setContentType</a>() and <a href="q3httpheader.html#hasContentType">hasContentType</a>().</p> <h3 class="fn"><a name="hasContentLength"></a>bool Q3HttpHeader::hasContentLength () const</h3> <p>Returns true if the header has an entry for the special HTTP header field <tt>content-length</tt>; otherwise returns false.</p> <p>See also <a href="q3httpheader.html#contentLength">contentLength</a>() and <a href="q3httpheader.html#setContentLength">setContentLength</a>().</p> <h3 class="fn"><a name="hasContentType"></a>bool Q3HttpHeader::hasContentType () const</h3> <p>Returns true if the header has an entry for the the special HTTP header field <tt>content-type</tt>; otherwise returns false.</p> <p>See also <a href="q3httpheader.html#contentType">contentType</a>() and <a href="q3httpheader.html#setContentType">setContentType</a>().</p> <h3 class="fn"><a name="hasKey"></a>bool Q3HttpHeader::hasKey ( const <a href="qstring.html">QString</a> & <i>key</i> ) const</h3> <p>Returns true if the HTTP header has an entry with the given <i>key</i>; otherwise returns false.</p> <p>See also <a href="q3httpheader.html#value">value</a>(), <a href="q3httpheader.html#setValue">setValue</a>(), and <a href="q3httpheader.html#keys">keys</a>().</p> <h3 class="fn"><a name="isValid"></a>bool Q3HttpHeader::isValid () const</h3> <p>Returns true if the HTTP header is valid; otherwise returns false.</p> <p>A <a href="q3httpheader.html">Q3HttpHeader</a> is invalid if it was created by parsing a malformed string.</p> <h3 class="fn"><a name="keys"></a><a href="qstringlist.html">QStringList</a> Q3HttpHeader::keys () const</h3> <p>Returns a list of the keys in the HTTP header.</p> <p>See also <a href="q3httpheader.html#hasKey">hasKey</a>().</p> <h3 class="fn"><a name="majorVersion"></a>int Q3HttpHeader::majorVersion () const <tt> [pure virtual]</tt></h3> <p>Returns the major protocol-version of the HTTP header.</p> <h3 class="fn"><a name="minorVersion"></a>int Q3HttpHeader::minorVersion () const <tt> [pure virtual]</tt></h3> <p>Returns the minor protocol-version of the HTTP header.</p> <h3 class="fn"><a name="removeValue"></a>void Q3HttpHeader::removeValue ( const <a href="qstring.html">QString</a> & <i>key</i> )</h3> <p>Removes the entry with the key <i>key</i> from the HTTP header.</p> <p>See also <a href="q3httpheader.html#value">value</a>() and <a href="q3httpheader.html#setValue">setValue</a>().</p> <h3 class="fn"><a name="setContentLength"></a>void Q3HttpHeader::setContentLength ( int <i>len</i> )</h3> <p>Sets the value of the special HTTP header field <tt>content-length</tt> to <i>len</i>.</p> <p>See also <a href="q3httpheader.html#contentLength">contentLength</a>() and <a href="q3httpheader.html#hasContentLength">hasContentLength</a>().</p> <h3 class="fn"><a name="setContentType"></a>void Q3HttpHeader::setContentType ( const <a href="qstring.html">QString</a> & <i>type</i> )</h3> <p>Sets the value of the special HTTP header field <tt>content-type</tt> to <i>type</i>.</p> <p>See also <a href="q3httpheader.html#contentType">contentType</a>() and <a href="q3httpheader.html#hasContentType">hasContentType</a>().</p> <h3 class="fn"><a name="setValue"></a>void Q3HttpHeader::setValue ( const <a href="qstring.html">QString</a> & <i>key</i>, const <a href="qstring.html">QString</a> & <i>value</i> )</h3> <p>Sets the value of the entry with the <i>key</i> to <i>value</i>.</p> <p>If no entry with <i>key</i> exists, a new entry with the given <i>key</i> and <i>value</i> is created. If an entry with the <i>key</i> already exists, its value is discarded and replaced with the given <i>value</i>.</p> <p>See also <a href="q3httpheader.html#value">value</a>(), <a href="q3httpheader.html#hasKey">hasKey</a>(), and <a href="q3httpheader.html#removeValue">removeValue</a>().</p> <h3 class="fn"><a name="toString"></a><a href="qstring.html">QString</a> Q3HttpHeader::toString () const <tt> [virtual]</tt></h3> <p>Returns a string representation of the HTTP header.</p> <p>The string is suitable for use by the constructor that takes a <a href="qstring.html">QString</a>. It consists of lines with the format: key, colon, space, value, "\r\n".</p> <h3 class="fn"><a name="value"></a><a href="qstring.html">QString</a> Q3HttpHeader::value ( const <a href="qstring.html">QString</a> & <i>key</i> ) const</h3> <p>Returns the value for the entry with the given <i>key</i>. If no entry has this <i>key</i>, an empty string is returned.</p> <p>See also <a href="q3httpheader.html#setValue">setValue</a>(), <a href="q3httpheader.html#removeValue">removeValue</a>(), <a href="q3httpheader.html#hasKey">hasKey</a>(), and <a href="q3httpheader.html#keys">keys</a>().</p> <h3 class="fn"><a name="operator-eq"></a>Q3HttpHeader & Q3HttpHeader::operator= ( const Q3HttpHeader & <i>h</i> )</h3> <p>Assigns <i>h</i> and returns a reference to this http header.</p> <p /><address><hr /><div align="center"> <table width="100%" cellspacing="0" border="0"><tr class="address"> <td width="30%">Copyright © 2008 <a href="trolltech.html">Trolltech</a></td> <td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td> <td width="30%" align="right"><div align="right">Qt 4.3.4</div></td> </tr></table></div></address></body> </html>