Sophie

Sophie

distrib > Fedora > 18 > x86_64 > by-pkgid > ff187cb994c94c614ecc64c5a8528b1b > files > 5534

qt-doc-4.8.5-10.fc18.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qhttpmultipart.cpp -->
  <title>Qt 4.8: QHttpPart Class Reference</title>
  <link rel="stylesheet" type="text/css" href="style/style.css" />
  <script src="scripts/jquery.js" type="text/javascript"></script>
  <script src="scripts/functions.js" type="text/javascript"></script>
  <link rel="stylesheet" type="text/css" href="style/superfish.css" />
  <link rel="stylesheet" type="text/css" href="style/narrow.css" />
  <!--[if IE]>
<meta name="MSSmartTagsPreventParsing" content="true">
<meta http-equiv="imagetoolbar" content="no">
<![endif]-->
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie6.css">
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie7.css">
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="style/style_ie8.css">
<![endif]-->

<script src="scripts/superfish.js" type="text/javascript"></script>
<script src="scripts/narrow.js" type="text/javascript"></script>

</head>
<body class="" onload="CheckEmptyAndLoadList();">
 <div class="header" id="qtdocheader">
    <div class="content"> 
    <div id="nav-logo">
      <a href="index.html">Home</a></div>
    <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
    <div id="narrowsearch"></div>
    <div id="nav-topright">
      <ul>
        <li class="nav-topright-home"><a href="http://qt.digia.com/">Qt HOME</a></li>
        <li class="nav-topright-dev"><a href="http://qt-project.org/">DEV</a></li>
        <li class="nav-topright-doc nav-topright-doc-active"><a href="http://qt-project.org/doc/">
          DOC</a></li>
        <li class="nav-topright-blog"><a href="http://blog.qt.digia.com/">BLOG</a></li>
      </ul>
    </div>
    <div id="shortCut">
      <ul>
        <li class="shortCut-topleft-inactive"><span><a href="index.html">Qt 4.8</a></span></li>
        <li class="shortCut-topleft-active"><a href="http://qt-project.org/doc/">ALL VERSIONS        </a></li>
      </ul>
     </div>
 <ul class="sf-menu" id="narrowmenu"> 
             <li><a href="#">API Lookup</a> 
                 <ul> 
                     <li><a href="classes.html">Class index</a></li> 
           <li><a href="functions.html">Function index</a></li> 
           <li><a href="modules.html">Modules</a></li> 
           <li><a href="namespaces.html">Namespaces</a></li> 
           <li><a href="qtglobal.html">Global Declarations</a></li> 
           <li><a href="qdeclarativeelements.html">QML elements</a></li> 
             </ul> 
             </li> 
             <li><a href="#">Qt Topics</a> 
                 <ul> 
                        <li><a href="qt-basic-concepts.html">Programming with Qt</a></li>  
                        <li><a href="qtquick.html">Device UIs &amp; Qt Quick</a></li>  
                        <li><a href="qt-gui-concepts.html">UI Design with Qt</a></li>  
                        <li><a href="supported-platforms.html">Supported Platforms</a></li>  
                        <li><a href="technology-apis.html">Qt and Key Technologies</a></li>  
                        <li><a href="best-practices.html">How-To's and Best Practices</a></li>  
              </ul> 
                 </li> 
                 <li><a href="#">Examples</a> 
                     <ul> 
                       <li><a href="all-examples.html">Examples</a></li> 
                       <li><a href="tutorials.html">Tutorials</a></li> 
                       <li><a href="demos.html">Demos</a></li> 
                       <li><a href="qdeclarativeexamples.html">QML Examples</a></li> 
                </ul> 
                     </li> 
                 </ul> 
    </div>
  </div>
  <div class="wrapper">
    <div class="hd">
      <span></span>
    </div>
    <div class="bd group">
      <div class="sidebar">
        <div class="searchlabel">
          Search index:</div>
        <div class="search" id="sidebarsearch">
          <form id="qtdocsearch" action="" onsubmit="return false;">
            <fieldset>
              <input type="text" name="searchstring" id="pageType" value="" />
 <div id="resultdialog"> 
 <a href="#" id="resultclose">Close</a> 
 <p id="resultlinks" class="all"><a href="#" id="showallresults">All</a> | <a href="#" id="showapiresults">API</a> | <a href="#" id="showarticleresults">Articles</a> | <a href="#" id="showexampleresults">Examples</a></p> 
 <p id="searchcount" class="all"><span id="resultcount"></span><span id="apicount"></span><span id="articlecount"></span><span id="examplecount"></span>&nbsp;results:</p> 
 <ul id="resultlist" class="all"> 
 </ul> 
 </div> 
            </fieldset>
          </form>
        </div>
        <div class="box first bottombar" id="lookup">
          <h2 title="API Lookup"><span></span>
            API Lookup</h2>
          <div  id="list001" class="list">
          <ul id="ul001" >
              <li class="defaultLink"><a href="classes.html">Class index</a></li>
              <li class="defaultLink"><a href="functions.html">Function index</a></li>
              <li class="defaultLink"><a href="modules.html">Modules</a></li>
              <li class="defaultLink"><a href="namespaces.html">Namespaces</a></li>
              <li class="defaultLink"><a href="qtglobal.html">Global Declarations</a></li>
              <li class="defaultLink"><a href="qdeclarativeelements.html">QML elements</a></li>
            </ul> 
          </div>
        </div>
        <div class="box bottombar" id="topics">
          <h2 title="Qt Topics"><span></span>
            Qt Topics</h2>
          <div id="list002" class="list">
            <ul id="ul002" >
               <li class="defaultLink"><a href="qt-basic-concepts.html">Programming with Qt</a></li> 
               <li class="defaultLink"><a href="qtquick.html">Device UIs &amp; Qt Quick</a></li> 
               <li class="defaultLink"><a href="qt-gui-concepts.html">UI Design with Qt</a></li> 
               <li class="defaultLink"><a href="supported-platforms.html">Supported Platforms</a></li>  
               <li class="defaultLink"><a href="technology-apis.html">Qt and Key Technologies</a></li> 
               <li class="defaultLink"><a href="best-practices.html">How-To's and Best Practices</a></li> 
            </ul>  
          </div>
        </div>
        <div class="box" id="examples">
          <h2 title="Examples"><span></span>
            Examples</h2>
          <div id="list003" class="list">
        <ul id="ul003">
              <li class="defaultLink"><a href="all-examples.html">Examples</a></li>
              <li class="defaultLink"><a href="tutorials.html">Tutorials</a></li>
              <li class="defaultLink"><a href="demos.html">Demos</a></li>
              <li class="defaultLink"><a href="qdeclarativeexamples.html">QML Examples</a></li>
            </ul> 
          </div>
        </div>
      </div>
      <div class="wrap">
        <div class="toolbar">
          <div class="breadcrumb toolblock">
            <ul>
              <li class="first"><a href="index.html">Home</a></li>
              <!--  Breadcrumbs go here -->
<li><a href="modules.html">Modules</a></li>
<li><a href="qtnetwork.html">QtNetwork</a></li>
<li>QHttpPart</li>
            </ul>
          </div>
          <div class="toolbuttons toolblock">
            <ul>
              <li id="smallA" class="t_button">A</li>
              <li id="medA" class="t_button active">A</li>
              <li id="bigA" class="t_button">A</li>
              <li id="print" class="t_button"><a href="javascript:this.print();">
                <span>Print</span></a></li>
            </ul>
        </div>
        </div>
        <div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<h1 class="title">QHttpPart Class Reference</h1>
<!-- $$$QHttpPart-brief -->
<p>The QHttpPart class holds a body part to be used inside a HTTP multipart MIME message. <a href="#details">More...</a></p>
<!-- @@@QHttpPart -->
<pre class="cpp"> <span class="preprocessor">#include &lt;QHttpPart&gt;</span></pre><p>This class was introduced in Qt 4.8.</p>
<ul>
<li><a href="qhttppart-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qhttppart.html#QHttpPart">QHttpPart</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qhttppart.html#QHttpPart-2">QHttpPart</a></b> ( const QHttpPart &amp; <i>other</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qhttppart.html#dtor.QHttpPart">~QHttpPart</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qhttppart.html#setBody">setBody</a></b> ( const QByteArray &amp; <i>body</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qhttppart.html#setBodyDevice">setBodyDevice</a></b> ( QIODevice * <i>device</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qhttppart.html#setHeader">setHeader</a></b> ( QNetworkRequest::KnownHeaders <i>header</i>, const QVariant &amp; <i>value</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qhttppart.html#setRawHeader">setRawHeader</a></b> ( const QByteArray &amp; <i>headerName</i>, const QByteArray &amp; <i>headerValue</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qhttppart.html#operator-not-eq">operator!=</a></b> ( const QHttpPart &amp; <i>other</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QHttpPart &amp; </td><td class="memItemRight bottomAlign"><b><a href="qhttppart.html#operator-eq">operator=</a></b> ( const QHttpPart &amp; <i>other</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qhttppart.html#operator-eq-eq">operator==</a></b> ( const QHttpPart &amp; <i>other</i> ) const</td></tr>
</table>
<a name="details"></a>
<!-- $$$QHttpPart-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The QHttpPart class holds a body part to be used inside a HTTP multipart MIME message.</p>
<p>The QHttpPart class holds a body part to be used inside a HTTP multipart MIME message (which is represented by the <a href="qhttpmultipart.html">QHttpMultiPart</a> class). A QHttpPart consists of a header block and a data block, which are separated by each other by two consecutive new lines. An example for one part would be:</p>
<pre class="cpp"> Content<span class="operator">-</span>Type: text<span class="operator">/</span>plain
 Content<span class="operator">-</span>Disposition: form<span class="operator">-</span>data; name<span class="operator">=</span><span class="string">&quot;text&quot;</span>

 here goes the body</pre>
<p>For setting headers, use <a href="qhttppart.html#setHeader">setHeader</a>() and <a href="qhttppart.html#setRawHeader">setRawHeader</a>(), which behave exactly like <a href="qnetworkrequest.html#setHeader">QNetworkRequest::setHeader</a>() and <a href="qnetworkrequest.html#setRawHeader">QNetworkRequest::setRawHeader</a>().</p>
<p>For reading small pieces of data, use <a href="qhttppart.html#setBody">setBody</a>(); for larger data blocks like e.g&#x2e; images, use <a href="qhttppart.html#setBodyDevice">setBodyDevice</a>(). The latter method saves memory by not copying the data internally, but reading directly from the device. This means that the device must be opened and readable at the moment when the multipart message containing the body part is sent on the network via <a href="qnetworkaccessmanager.html#post">QNetworkAccessManager::post</a>().</p>
<p>To construct a QHttpPart with a small body, consider the following snippet (this produces the data shown in the example above):</p>
<pre class="cpp"> <span class="type">QHttpPart</span> textPart;
 textPart<span class="operator">.</span><a href="qhttppart.html#setHeader">setHeader</a>(<span class="type"><a href="qnetworkrequest.html">QNetworkRequest</a></span><span class="operator">::</span>ContentTypeHeader<span class="operator">,</span> <span class="type"><a href="qvariant.html">QVariant</a></span>(<span class="string">&quot;text/plain&quot;</span>));
 textPart<span class="operator">.</span><a href="qhttppart.html#setHeader">setHeader</a>(<span class="type"><a href="qnetworkrequest.html">QNetworkRequest</a></span><span class="operator">::</span>ContentDispositionHeader<span class="operator">,</span> <span class="type"><a href="qvariant.html">QVariant</a></span>(<span class="string">&quot;form-data; name=\&quot;text\&quot;&quot;</span>));
 textPart<span class="operator">.</span><a href="qhttppart.html#setBody">setBody</a>(<span class="string">&quot;here goes the body&quot;</span>);</pre>
<p>To construct a QHttpPart reading from a device (e.g&#x2e; a file), the following can be applied:</p>
<pre class="cpp"> <span class="type">QHttpPart</span> imagePart;
 imagePart<span class="operator">.</span><a href="qhttppart.html#setHeader">setHeader</a>(<span class="type"><a href="qnetworkrequest.html">QNetworkRequest</a></span><span class="operator">::</span>ContentTypeHeader<span class="operator">,</span> <span class="type"><a href="qvariant.html">QVariant</a></span>(<span class="string">&quot;image/jpeg&quot;</span>));
 imagePart<span class="operator">.</span><a href="qhttppart.html#setHeader">setHeader</a>(<span class="type"><a href="qnetworkrequest.html">QNetworkRequest</a></span><span class="operator">::</span>ContentDispositionHeader<span class="operator">,</span> <span class="type"><a href="qvariant.html">QVariant</a></span>(<span class="string">&quot;form-data; name=\&quot;image\&quot;&quot;</span>));
 imagePart<span class="operator">.</span><a href="qhttppart.html#setRawHeader">setRawHeader</a>(<span class="string">&quot;Content-ID&quot;</span><span class="operator">,</span> <span class="string">&quot;my@content.id&quot;</span>); <span class="comment">// add any headers you like via setRawHeader()</span>
 <span class="type"><a href="qfile.html">QFile</a></span> <span class="operator">*</span>file <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qfile.html">QFile</a></span>(<span class="string">&quot;image.jpg&quot;</span>);
 file<span class="operator">-</span><span class="operator">&gt;</span>open(<span class="type"><a href="qiodevice.html">QIODevice</a></span><span class="operator">::</span>ReadOnly);
 imagePart<span class="operator">.</span><a href="qhttppart.html#setBodyDevice">setBodyDevice</a>(file);</pre>
<p>Be aware that QHttpPart does not take ownership of the device when set, so it is the developer's responsibility to destroy it when it is not needed anymore. A good idea might be to set the multipart message as parent object for the device, as documented at the documentation for <a href="qhttpmultipart.html">QHttpMultiPart</a>.</p>
</div>
<p><b>See also </b><a href="qhttpmultipart.html">QHttpMultiPart</a> and <a href="qnetworkaccessmanager.html">QNetworkAccessManager</a>.</p>
<!-- @@@QHttpPart -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QHttpPart[overload1]$$$QHttpPart -->
<h3 class="fn"><a name="QHttpPart"></a>QHttpPart::<span class="name">QHttpPart</span> ()</h3>
<p>Constructs an empty <a href="qhttppart.html">QHttpPart</a> object.</p>
<!-- @@@QHttpPart -->
<!-- $$$QHttpPart$$$QHttpPartconstQHttpPart& -->
<h3 class="fn"><a name="QHttpPart-2"></a>QHttpPart::<span class="name">QHttpPart</span> ( const <span class="type">QHttpPart</span> &amp; <i>other</i> )</h3>
<p>Creates a copy of <i>other</i>.</p>
<!-- @@@QHttpPart -->
<!-- $$$~QHttpPart[overload1]$$$~QHttpPart -->
<h3 class="fn"><a name="dtor.QHttpPart"></a>QHttpPart::<span class="name">~QHttpPart</span> ()</h3>
<p>Destroys this <a href="qhttppart.html">QHttpPart</a>.</p>
<!-- @@@~QHttpPart -->
<!-- $$$setBody[overload1]$$$setBodyconstQByteArray& -->
<h3 class="fn"><a name="setBody"></a><span class="type">void</span> QHttpPart::<span class="name">setBody</span> ( const <span class="type"><a href="qbytearray.html">QByteArray</a></span> &amp; <i>body</i> )</h3>
<p>Sets the body of this MIME part to <i>body</i>. The body set with this method will be used unless the device is set via <a href="qhttppart.html#setBodyDevice">setBodyDevice</a>(). For a large amount of data (e.g&#x2e; an image), use <a href="qhttppart.html#setBodyDevice">setBodyDevice</a>(), which will not copy the data internally.</p>
<p><b>See also </b><a href="qhttppart.html#setBodyDevice">setBodyDevice</a>().</p>
<!-- @@@setBody -->
<!-- $$$setBodyDevice[overload1]$$$setBodyDeviceQIODevice* -->
<h3 class="fn"><a name="setBodyDevice"></a><span class="type">void</span> QHttpPart::<span class="name">setBodyDevice</span> ( <span class="type"><a href="qiodevice.html">QIODevice</a></span> * <i>device</i> )</h3>
<p>Sets the device to read the content from to <i>device</i>. For large amounts of data this method should be preferred over <a href="qhttppart.html#setBody">setBody</a>(), because the content is not copied when using this method, but read directly from the device. <i>device</i> must be open and readable. <a href="qhttppart.html">QHttpPart</a> does not take ownership of <i>device</i>, i.e&#x2e; the device must be closed and destroyed if necessary. if <i>device</i> is sequential (e.g&#x2e; sockets, but not files), <a href="qnetworkaccessmanager.html#post">QNetworkAccessManager::post</a>() should be called after <i>device</i> has emitted finished(). For unsetting the device and using data set via <a href="qhttppart.html#setBody">setBody</a>(), use &quot;setBodyDevice(0)&quot;.</p>
<p><b>See also </b><a href="qhttppart.html#setBody">setBody</a>() and <a href="qnetworkaccessmanager.html#post">QNetworkAccessManager::post</a>().</p>
<!-- @@@setBodyDevice -->
<!-- $$$setHeader[overload1]$$$setHeaderQNetworkRequest::KnownHeadersconstQVariant& -->
<h3 class="fn"><a name="setHeader"></a><span class="type">void</span> QHttpPart::<span class="name">setHeader</span> ( <span class="type"><a href="qnetworkrequest.html#KnownHeaders-enum">QNetworkRequest::KnownHeaders</a></span> <i>header</i>, const <span class="type"><a href="qvariant.html">QVariant</a></span> &amp; <i>value</i> )</h3>
<p>Sets the value of the known header <i>header</i> to be <i>value</i>, overriding any previously set headers.</p>
<p><b>See also </b><a href="qnetworkrequest.html#KnownHeaders-enum">QNetworkRequest::KnownHeaders</a>, <a href="qhttppart.html#setRawHeader">setRawHeader</a>(), and <a href="qnetworkrequest.html#setHeader">QNetworkRequest::setHeader</a>().</p>
<!-- @@@setHeader -->
<!-- $$$setRawHeader[overload1]$$$setRawHeaderconstQByteArray&constQByteArray& -->
<h3 class="fn"><a name="setRawHeader"></a><span class="type">void</span> QHttpPart::<span class="name">setRawHeader</span> ( const <span class="type"><a href="qbytearray.html">QByteArray</a></span> &amp; <i>headerName</i>, const <span class="type"><a href="qbytearray.html">QByteArray</a></span> &amp; <i>headerValue</i> )</h3>
<p>Sets the header <i>headerName</i> to be of value <i>headerValue</i>. If <i>headerName</i> corresponds to a known header (see <a href="qnetworkrequest.html#KnownHeaders-enum">QNetworkRequest::KnownHeaders</a>), the raw format will be parsed and the corresponding &quot;cooked&quot; header will be set as well.</p>
<p>Note: setting the same header twice overrides the previous setting. To accomplish the behaviour of multiple HTTP headers of the same name, you should concatenate the two values, separating them with a comma (&quot;,&quot;) and set one single raw header.</p>
<p><b>See also </b><a href="qnetworkrequest.html#KnownHeaders-enum">QNetworkRequest::KnownHeaders</a>, <a href="qhttppart.html#setHeader">setHeader</a>(), and <a href="qnetworkrequest.html#setRawHeader">QNetworkRequest::setRawHeader</a>().</p>
<!-- @@@setRawHeader -->
<!-- $$$operator!=[overload1]$$$operator!=constQHttpPart& -->
<h3 class="fn"><a name="operator-not-eq"></a><span class="type">bool</span> QHttpPart::<span class="name">operator!=</span> ( const <span class="type">QHttpPart</span> &amp; <i>other</i> ) const</h3>
<p>Returns true if this object is not the same as <i>other</i>.</p>
<p><b>See also </b><a href="qhttppart.html#operator-eq-eq">operator==</a>().</p>
<!-- @@@operator!= -->
<!-- $$$operator=[overload1]$$$operator=constQHttpPart& -->
<h3 class="fn"><a name="operator-eq"></a><span class="type">QHttpPart</span> &amp; QHttpPart::<span class="name">operator=</span> ( const <span class="type">QHttpPart</span> &amp; <i>other</i> )</h3>
<p>Creates a copy of <i>other</i>.</p>
<!-- @@@operator= -->
<!-- $$$operator==[overload1]$$$operator==constQHttpPart& -->
<h3 class="fn"><a name="operator-eq-eq"></a><span class="type">bool</span> QHttpPart::<span class="name">operator==</span> ( const <span class="type">QHttpPart</span> &amp; <i>other</i> ) const</h3>
<p>Returns true if this object is the same as <i>other</i> (i.e&#x2e;, if they have the same headers and body).</p>
<p><b>See also </b><a href="qhttppart.html#operator-not-eq">operator!=</a>().</p>
<!-- @@@operator== -->
</div>
      </div>
    </div>
    </div> 
    <div class="ft">
      <span></span>
    </div>
  </div> 
  <div class="footer">
    <p>
      <acronym title="Copyright">&copy;</acronym> 2013 Digia Plc and/or its
      subsidiaries. Documentation contributions included herein are the copyrights of
      their respective owners.</p>
    <br />
    <p>
      The documentation provided herein is licensed under the terms of the
      <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation
      License version 1.3</a> as published by the Free Software Foundation.</p>
    <p>
      Documentation sources may be obtained from <a href="http://www.qt-project.org">
      www.qt-project.org</a>.</p>
    <br />
    <p>
      Digia, Qt and their respective logos are trademarks of Digia Plc 
      in Finland and/or other countries worldwide. All other trademarks are property
      of their respective owners. <a title="Privacy Policy"
      href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
  </div>

  <script src="scripts/functions.js" type="text/javascript"></script>
</body>
</html>