1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QHttpHeader Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></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="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QHttpHeader Class Reference<br /><sup><sup>[<a href="qtnetwork.html">QtNetwork</a> module]</sup></sup></h1><p>The QHttpHeader class contains header information for HTTP.
<a href="#details">More...</a></p>
<p>Inherited by <a href="qhttprequestheader.html">QHttpRequestHeader</a> and <a href="qhttpresponseheader.html">QHttpResponseHeader</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qhttpheader.html#QHttpHeader">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qhttpheader.html#QHttpHeader-2">__init__</a></b> (<i>self</i>, QHttpHeader <i>header</i>)</li><li><div class="fn" /><b><a href="qhttpheader.html#QHttpHeader-3">__init__</a></b> (<i>self</i>, QString <i>str</i>)</li><li><div class="fn" /><b><a href="qhttpheader.html#addValue">addValue</a></b> (<i>self</i>, QString <i>key</i>, QString <i>value</i>)</li><li><div class="fn" />QStringList <b><a href="qhttpheader.html#allValues">allValues</a></b> (<i>self</i>, QString <i>key</i>)</li><li><div class="fn" />int <b><a href="qhttpheader.html#contentLength">contentLength</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qhttpheader.html#contentType">contentType</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qhttpheader.html#hasContentLength">hasContentLength</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qhttpheader.html#hasContentType">hasContentType</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qhttpheader.html#hasKey">hasKey</a></b> (<i>self</i>, QString <i>key</i>)</li><li><div class="fn" />bool <b><a href="qhttpheader.html#isValid">isValid</a></b> (<i>self</i>)</li><li><div class="fn" />QStringList <b><a href="qhttpheader.html#keys">keys</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qhttpheader.html#majorVersion">majorVersion</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qhttpheader.html#minorVersion">minorVersion</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qhttpheader.html#parse">parse</a></b> (<i>self</i>, QString <i>str</i>)</li><li><div class="fn" />bool <b><a href="qhttpheader.html#parseLine">parseLine</a></b> (<i>self</i>, QString <i>line</i>, int <i>number</i>)</li><li><div class="fn" /><b><a href="qhttpheader.html#removeAllValues">removeAllValues</a></b> (<i>self</i>, QString <i>key</i>)</li><li><div class="fn" /><b><a href="qhttpheader.html#removeValue">removeValue</a></b> (<i>self</i>, QString <i>key</i>)</li><li><div class="fn" /><b><a href="qhttpheader.html#setContentLength">setContentLength</a></b> (<i>self</i>, int <i>len</i>)</li><li><div class="fn" /><b><a href="qhttpheader.html#setContentType">setContentType</a></b> (<i>self</i>, QString <i>type</i>)</li><li><div class="fn" /><b><a href="qhttpheader.html#setValid">setValid</a></b> (<i>self</i>, bool)</li><li><div class="fn" /><b><a href="qhttpheader.html#setValue">setValue</a></b> (<i>self</i>, QString <i>key</i>, QString <i>value</i>)</li><li><div class="fn" /><b><a href="qhttpheader.html#setValues">setValues</a></b> (<i>self</i>, list-of-tuple-of-QString-QString <i>values</i>)</li><li><div class="fn" />QString <b><a href="qhttpheader.html#toString">toString</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qhttpheader.html#value">value</a></b> (<i>self</i>, QString <i>key</i>)</li><li><div class="fn" />list-of-tuple-of-QString-QString <b><a href="qhttpheader.html#values">values</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QHttpHeader class contains header information for HTTP.</p>
<p>In most cases you should use the more specialized derivatives of
this class, <a href="qhttpresponseheader.html">QHttpResponseHeader</a> and <a href="qhttprequestheader.html">QHttpRequestHeader</a>, rather than
directly using QHttpHeader.</p>
<p>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:</p>
<pre class="cpp">
content<span class="operator">-</span>type: text<span class="operator">/</span>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="qhttpheader.html#value">value</a>() and <a href="qhttpheader.html#setValue">setValue</a>(), e.g.</p>
<pre class="cpp">
header<span class="operator">.</span><a href="qhttpheader.html#setValue">setValue</a>(<span class="string">"content-type"</span><span class="operator">,</span> <span class="string">"text/html"</span>);
<span class="type"><a href="qstring.html">QString</a></span> contentType <span class="operator">=</span> header<span class="operator">.</span><a href="qhttpheader.html#value">value</a>(<span class="string">"content-type"</span>);
</pre>
<p>Some fields are so common that getters and setters are provided
for them as a convenient alternative to using <a href="qhttpheader.html#value">value</a>() and <a href="qhttpheader.html#setValue">setValue</a>(), e.g. <a href="qhttpheader.html#contentLength">contentLength</a>() and <a href="qhttpheader.html#contentType">contentType</a>(), <a href="qhttpheader.html#setContentLength">setContentLength</a>() and
<a href="qhttpheader.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>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QHttpHeader" />QHttpHeader.__init__ (<i>self</i>)</h3><p>Constructs an empty HTTP header.</p>
<h3 class="fn"><a name="QHttpHeader-2" />QHttpHeader.__init__ (<i>self</i>, <a href="qhttpheader.html">QHttpHeader</a> <i>header</i>)</h3><p>Constructs a copy of <i>header</i>.</p>
<h3 class="fn"><a name="QHttpHeader-3" />QHttpHeader.__init__ (<i>self</i>, QString <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="addValue" />QHttpHeader.addValue (<i>self</i>, QString <i>key</i>, QString <i>value</i>)</h3><p>Adds a new entry with the <i>key</i> and <i>value</i>.</p>
<h3 class="fn"><a name="allValues" />QStringList QHttpHeader.allValues (<i>self</i>, QString <i>key</i>)</h3><p>Returns all the entries with the given <i>key</i>. If no entry
has this <i>key</i>, an empty string list is returned.</p>
<h3 class="fn"><a name="contentLength" />int QHttpHeader.contentLength (<i>self</i>)</h3><p>Returns the value of the special HTTP header field
<tt>content-length</tt>.</p>
<p><b>See also</b> <a href="qhttpheader.html#setContentLength">setContentLength</a>() and
<a href="qhttpheader.html#hasContentLength">hasContentLength</a>().</p>
<h3 class="fn"><a name="contentType" />QString QHttpHeader.contentType (<i>self</i>)</h3><p>Returns the value of the special HTTP header field
<tt>content-type</tt>.</p>
<p><b>See also</b> <a href="qhttpheader.html#setContentType">setContentType</a>() and <a href="qhttpheader.html#hasContentType">hasContentType</a>().</p>
<h3 class="fn"><a name="hasContentLength" />bool QHttpHeader.hasContentLength (<i>self</i>)</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><b>See also</b> <a href="qhttpheader.html#contentLength">contentLength</a>() and <a href="qhttpheader.html#setContentLength">setContentLength</a>().</p>
<h3 class="fn"><a name="hasContentType" />bool QHttpHeader.hasContentType (<i>self</i>)</h3><p>Returns true if the header has an entry for the special HTTP
header field <tt>content-type</tt>; otherwise returns false.</p>
<p><b>See also</b> <a href="qhttpheader.html#contentType">contentType</a>() and <a href="qhttpheader.html#setContentType">setContentType</a>().</p>
<h3 class="fn"><a name="hasKey" />bool QHttpHeader.hasKey (<i>self</i>, QString <i>key</i>)</h3><p>Returns true if the HTTP header has an entry with the given
<i>key</i>; otherwise returns false.</p>
<p><b>See also</b> <a href="qhttpheader.html#value">value</a>(),
<a href="qhttpheader.html#setValue">setValue</a>(), and <a href="qhttpheader.html#keys">keys</a>().</p>
<h3 class="fn"><a name="isValid" />bool QHttpHeader.isValid (<i>self</i>)</h3><p>Returns true if the HTTP header is valid; otherwise returns
false.</p>
<p>A <a class="obsolete" href="qhttpheader.html">QHttpHeader</a> is
invalid if it was created by parsing a malformed string.</p>
<h3 class="fn"><a name="keys" />QStringList QHttpHeader.keys (<i>self</i>)</h3><p>Returns a list of the keys in the HTTP header.</p>
<p><b>See also</b> <a href="qhttpheader.html#hasKey">hasKey</a>().</p>
<h3 class="fn"><a name="majorVersion" />int QHttpHeader.majorVersion (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns the major protocol-version of the HTTP header.</p>
<h3 class="fn"><a name="minorVersion" />int QHttpHeader.minorVersion (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns the minor protocol-version of the HTTP header.</p>
<h3 class="fn"><a name="parse" />bool QHttpHeader.parse (<i>self</i>, QString <i>str</i>)</h3><h3 class="fn"><a name="parseLine" />bool QHttpHeader.parseLine (<i>self</i>, QString <i>line</i>, int <i>number</i>)</h3><h3 class="fn"><a name="removeAllValues" />QHttpHeader.removeAllValues (<i>self</i>, QString <i>key</i>)</h3><p>Removes all the entries with the key <i>key</i> from the HTTP
header.</p>
<h3 class="fn"><a name="removeValue" />QHttpHeader.removeValue (<i>self</i>, QString <i>key</i>)</h3><p>Removes the entry with the key <i>key</i> from the HTTP
header.</p>
<p><b>See also</b> <a href="qhttpheader.html#value">value</a>() and
<a href="qhttpheader.html#setValue">setValue</a>().</p>
<h3 class="fn"><a name="setContentLength" />QHttpHeader.setContentLength (<i>self</i>, 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><b>See also</b> <a href="qhttpheader.html#contentLength">contentLength</a>() and <a href="qhttpheader.html#hasContentLength">hasContentLength</a>().</p>
<h3 class="fn"><a name="setContentType" />QHttpHeader.setContentType (<i>self</i>, QString <i>type</i>)</h3><p>Sets the value of the special HTTP header field
<tt>content-type</tt> to <i>type</i>.</p>
<p><b>See also</b> <a href="qhttpheader.html#contentType">contentType</a>() and <a href="qhttpheader.html#hasContentType">hasContentType</a>().</p>
<h3 class="fn"><a name="setValid" />QHttpHeader.setValid (<i>self</i>, bool)</h3><h3 class="fn"><a name="setValue" />QHttpHeader.setValue (<i>self</i>, QString <i>key</i>, QString <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, the first value is discarded and
replaced with the given <i>value</i>.</p>
<p><b>See also</b> <a href="qhttpheader.html#value">value</a>(),
<a href="qhttpheader.html#hasKey">hasKey</a>(), and <a href="qhttpheader.html#removeValue">removeValue</a>().</p>
<h3 class="fn"><a name="setValues" />QHttpHeader.setValues (<i>self</i>, list-of-tuple-of-QString-QString <i>values</i>)</h3><p>Sets the header entries to be the list of key value pairs in
<i>values</i>.</p>
<p><b>See also</b> <a href="qhttpheader.html#values">values</a>().</p>
<h3 class="fn"><a name="toString" />QString QHttpHeader.toString (<i>self</i>)</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" />QString QHttpHeader.value (<i>self</i>, QString <i>key</i>)</h3><p>Returns the first 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><b>See also</b> <a href="qhttpheader.html#setValue">setValue</a>(), <a href="qhttpheader.html#removeValue">removeValue</a>(), <a href="qhttpheader.html#hasKey">hasKey</a>(), and <a href="qhttpheader.html#keys">keys</a>().</p>
<h3 class="fn"><a name="values" />list-of-tuple-of-QString-QString QHttpHeader.values (<i>self</i>)</h3><p>Returns all the entries in the header.</p>
<p><b>See also</b> <a href="qhttpheader.html#setValues">setValues</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.9.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.2</td></tr></table></div></address></body></html>
|