1
<?xml version="1.0" encoding="iso-8859-1"?>
3
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/qt3support/network/q3http.cpp -->
7
<title>Qt 4.0: Q3HttpHeader Class Reference</title>
8
<style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
9
a:link { color: #004faf; text-decoration: none }
10
a:visited { color: #672967; text-decoration: none }
11
td.postheader { font-family: sans-serif }
12
tr.address { font-family: sans-serif }
13
body { background: #ffffff; color: black; }</style>
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
19
<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="annotated.html"><font color="#004faf">Annotated</font></a> · <a href="groups.html"><font color="#004faf">Grouped Classes</font></a> · <a href="functions.html"><font color="#004faf">Functions</font></a></td>
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">Q3HttpHeader Class Reference</h1>
21
<p>The Q3HttpHeader class contains header information for HTTP. <a href="#details">More...</a></p>
22
<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 the <a href="porting4.html">Porting Guide</a> for more information.</p>
23
<p>Part of the <a href="qt3support.html">Qt3Support</a> module.</p>
24
<p>Inherited by <a href="q3httprequestheader.html">Q3HttpRequestHeader</a> and <a href="q3httpresponseheader.html">Q3HttpResponseHeader</a>.</p>
26
<li><a href="q3httpheader-members.html">List of all members, including inherited members</a></li>
28
<a name="public-functions"></a>
29
<h3>Public Functions</h3>
31
<li><div class="fn"/><b><a href="q3httpheader.html#Q3HttpHeader">Q3HttpHeader</a></b> ()</li>
32
<li><div class="fn"/><b><a href="q3httpheader.html#Q3HttpHeader-2">Q3HttpHeader</a></b> ( const Q3HttpHeader & <i>header</i> )</li>
33
<li><div class="fn"/><b><a href="q3httpheader.html#Q3HttpHeader-3">Q3HttpHeader</a></b> ( const QString & <i>str</i> )</li>
34
<li><div class="fn"/>virtual <b><a href="q3httpheader.html#dtor.Q3HttpHeader">~Q3HttpHeader</a></b> ()</li>
35
<li><div class="fn"/>uint <b><a href="q3httpheader.html#contentLength">contentLength</a></b> () const</li>
36
<li><div class="fn"/>QString <b><a href="q3httpheader.html#contentType">contentType</a></b> () const</li>
37
<li><div class="fn"/>bool <b><a href="q3httpheader.html#hasContentLength">hasContentLength</a></b> () const</li>
38
<li><div class="fn"/>bool <b><a href="q3httpheader.html#hasContentType">hasContentType</a></b> () const</li>
39
<li><div class="fn"/>bool <b><a href="q3httpheader.html#hasKey">hasKey</a></b> ( const QString & <i>key</i> ) const</li>
40
<li><div class="fn"/>bool <b><a href="q3httpheader.html#isValid">isValid</a></b> () const</li>
41
<li><div class="fn"/>QStringList <b><a href="q3httpheader.html#keys">keys</a></b> () const</li>
42
<li><div class="fn"/>virtual int <b><a href="q3httpheader.html#majorVersion">majorVersion</a></b> () const = 0</li>
43
<li><div class="fn"/>virtual int <b><a href="q3httpheader.html#minorVersion">minorVersion</a></b> () const = 0</li>
44
<li><div class="fn"/>void <b><a href="q3httpheader.html#removeValue">removeValue</a></b> ( const QString & <i>key</i> )</li>
45
<li><div class="fn"/>void <b><a href="q3httpheader.html#setContentLength">setContentLength</a></b> ( int <i>len</i> )</li>
46
<li><div class="fn"/>void <b><a href="q3httpheader.html#setContentType">setContentType</a></b> ( const QString & <i>type</i> )</li>
47
<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>
48
<li><div class="fn"/>virtual QString <b><a href="q3httpheader.html#toString">toString</a></b> () const</li>
49
<li><div class="fn"/>QString <b><a href="q3httpheader.html#value">value</a></b> ( const QString & <i>key</i> ) const</li>
50
<li><div class="fn"/>Q3HttpHeader & <b><a href="q3httpheader.html#operator-eq">operator=</a></b> ( const Q3HttpHeader & <i>h</i> )</li>
52
<a name="details"></a>
54
<h2>Detailed Description</h2>
55
<p>The Q3HttpHeader class contains header information for HTTP.</p>
56
<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>
57
<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>
58
<pre> content-type: text/html</pre>
59
<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>
60
<pre> header.setValue( "content-type", "text/html" );
61
QString contentType = header.value( "content-type" );</pre>
62
<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>
63
<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>
64
<p>See also <a href="q3httprequestheader.html">Q3HttpRequestHeader</a> and <a href="q3httpresponseheader.html">Q3HttpResponseHeader</a>.</p>
66
<h2>Member Function Documentation</h2>
67
<h3 class="fn"><a name="Q3HttpHeader"></a>Q3HttpHeader::Q3HttpHeader ()</h3>
68
<p>Constructs an empty HTTP header.</p>
69
<h3 class="fn"><a name="Q3HttpHeader-2"></a>Q3HttpHeader::Q3HttpHeader ( const Q3HttpHeader & <i>header</i> )</h3>
70
<p>Constructs a copy of <i>header</i>.</p>
71
<h3 class="fn"><a name="Q3HttpHeader-3"></a>Q3HttpHeader::Q3HttpHeader ( const <a href="qstring.html">QString</a> & <i>str</i> )</h3>
72
<p>Constructs a HTTP header for <i>str</i>.</p>
73
<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>
74
<h3 class="fn"><a name="dtor.Q3HttpHeader"></a>Q3HttpHeader::~Q3HttpHeader () <tt> [virtual]</tt></h3>
76
<h3 class="fn"><a name="contentLength"></a><a href="qtglobal.html#uint-typedef">uint</a> Q3HttpHeader::contentLength () const</h3>
77
<p>Returns the value of the special HTTP header field <tt>content-length</tt>.</p>
78
<p>See also <a href="q3httpheader.html#setContentLength">setContentLength</a>() and <a href="q3httpheader.html#hasContentLength">hasContentLength</a>().</p>
79
<h3 class="fn"><a name="contentType"></a><a href="qstring.html">QString</a> Q3HttpHeader::contentType () const</h3>
80
<p>Returns the value of the special HTTP header field <tt>content-type</tt>.</p>
81
<p>See also <a href="q3httpheader.html#setContentType">setContentType</a>() and <a href="q3httpheader.html#hasContentType">hasContentType</a>().</p>
82
<h3 class="fn"><a name="hasContentLength"></a>bool Q3HttpHeader::hasContentLength () const</h3>
83
<p>Returns true if the header has an entry for the special HTTP header field <tt>content-length</tt>; otherwise returns false.</p>
84
<p>See also <a href="q3httpheader.html#contentLength">contentLength</a>() and <a href="q3httpheader.html#setContentLength">setContentLength</a>().</p>
85
<h3 class="fn"><a name="hasContentType"></a>bool Q3HttpHeader::hasContentType () const</h3>
86
<p>Returns true if the header has an entry for the the special HTTP header field <tt>content-type</tt>; otherwise returns false.</p>
87
<p>See also <a href="q3httpheader.html#contentType">contentType</a>() and <a href="q3httpheader.html#setContentType">setContentType</a>().</p>
88
<h3 class="fn"><a name="hasKey"></a>bool Q3HttpHeader::hasKey ( const <a href="qstring.html">QString</a> & <i>key</i> ) const</h3>
89
<p>Returns true if the HTTP header has an entry with the given <i>key</i>; otherwise returns false.</p>
90
<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>
91
<h3 class="fn"><a name="isValid"></a>bool Q3HttpHeader::isValid () const</h3>
92
<p>Returns true if the HTTP header is valid; otherwise returns false.</p>
93
<p>A <a href="q3httpheader.html">Q3HttpHeader</a> is invalid if it was created by parsing a malformed string.</p>
94
<h3 class="fn"><a name="keys"></a><a href="qstringlist.html">QStringList</a> Q3HttpHeader::keys () const</h3>
95
<p>Returns a list of the keys in the HTTP header.</p>
96
<p>See also <a href="q3httpheader.html#hasKey">hasKey</a>().</p>
97
<h3 class="fn"><a name="majorVersion"></a>int Q3HttpHeader::majorVersion () const <tt> [pure virtual]</tt></h3>
98
<p>Returns the major protocol-version of the HTTP header.</p>
99
<h3 class="fn"><a name="minorVersion"></a>int Q3HttpHeader::minorVersion () const <tt> [pure virtual]</tt></h3>
100
<p>Returns the minor protocol-version of the HTTP header.</p>
101
<h3 class="fn"><a name="removeValue"></a>void Q3HttpHeader::removeValue ( const <a href="qstring.html">QString</a> & <i>key</i> )</h3>
102
<p>Removes the entry with the key <i>key</i> from the HTTP header.</p>
103
<p>See also <a href="q3httpheader.html#value">value</a>() and <a href="q3httpheader.html#setValue">setValue</a>().</p>
104
<h3 class="fn"><a name="setContentLength"></a>void Q3HttpHeader::setContentLength ( int <i>len</i> )</h3>
105
<p>Sets the value of the special HTTP header field <tt>content-length</tt> to <i>len</i>.</p>
106
<p>See also <a href="q3httpheader.html#contentLength">contentLength</a>() and <a href="q3httpheader.html#hasContentLength">hasContentLength</a>().</p>
107
<h3 class="fn"><a name="setContentType"></a>void Q3HttpHeader::setContentType ( const <a href="qstring.html">QString</a> & <i>type</i> )</h3>
108
<p>Sets the value of the special HTTP header field <tt>content-type</tt> to <i>type</i>.</p>
109
<p>See also <a href="q3httpheader.html#contentType">contentType</a>() and <a href="q3httpheader.html#hasContentType">hasContentType</a>().</p>
110
<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>
111
<p>Sets the value of the entry with the <i>key</i> to <i>value</i>.</p>
112
<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>
113
<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>
114
<h3 class="fn"><a name="toString"></a><a href="qstring.html">QString</a> Q3HttpHeader::toString () const <tt> [virtual]</tt></h3>
115
<p>Returns a string representation of the HTTP header.</p>
116
<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>
117
<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>
118
<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>
119
<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>
120
<h3 class="fn"><a name="operator-eq"></a>Q3HttpHeader & Q3HttpHeader::operator= ( const Q3HttpHeader & <i>h</i> )</h3>
121
<p>Assigns <i>h</i> and returns a reference to this http header.</p>
122
<p /><address><hr /><div align="center">
123
<table width="100%" cellspacing="0" border="0"><tr class="address">
124
<td width="30%">Copyright © 2005 <a href="trolltech.html">Trolltech</a></td>
125
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
126
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
127
</tr></table></div></address></body>