http://wiki.crossplatform.ru/index.php?title=Qt:%D0%94%D0%BE%D0%BA%D1%83%D0%BC%D0%B5%D0%BD%D1%82%D0%B0%D1%86%D0%B8%D1%8F_4.3.2/qhttp&feed=atom&action=historyQt:Документация 4.3.2/qhttp - История изменений2024-03-28T13:07:49ZИстория изменений этой страницы в викиMediaWiki 1.15.1http://wiki.crossplatform.ru/index.php?title=Qt:%D0%94%D0%BE%D0%BA%D1%83%D0%BC%D0%B5%D0%BD%D1%82%D0%B0%D1%86%D0%B8%D1%8F_4.3.2/qhttp&diff=4143&oldid=prevRoot: Новая: {{Qt4.3.2_header}} =QHttp Class Reference<br /><sup><sup>[модуль QtNetwork ] </sup></sup>= The QHttp class provides an implement...2009-01-12T10:45:47Z<p>Новая: {{Qt4.3.2_header}} =QHttp Class Reference<br /><sup><sup>[модуль <a href="/index.php/Qt:%D0%94%D0%BE%D0%BA%D1%83%D0%BC%D0%B5%D0%BD%D1%82%D0%B0%D1%86%D0%B8%D1%8F_4.3.2/qtnetwork" title="Qt:Документация 4.3.2/qtnetwork"> QtNetwork</a> ] </sup></sup>= The QHttp class provides an implement...</p>
<p><b>Новая страница</b></p><div>{{Qt4.3.2_header}}<br />
<br />
=QHttp Class Reference<br /><sup><sup>[модуль [[Qt:Документация 4.3.2/qtnetwork | QtNetwork]] ] </sup></sup>=<br />
<br />
The QHttp class provides an implementation of the HTTP protocol. [[#details | Далее...]]<br />
<source lang="cpp-qt"> #include <QHttp></source> <br />
Inherits [[Qt:Документация 4.3.2/qobject | QObject]].<br />
<br />
'''Примечание:''' все функции в этом классе [[Qt:Документация 4.3.2/threads#reentrant | реентерабельны]].<br />
<br />
*[[Qt:Документация 4.3.2/qhttp-members | Список всех членов, включая унаследованные]]<br />
*[[Qt:Документация 4.3.2/qhttp-obsolete | Obsolete members]]<br />
*[[Qt:Документация 4.3.2/qhttp-qt3 | Поддерживаемые члены Qt 3]]<br />
<div id="public-types"></div><br />
===Открытые типы===<br />
<br />
*enum '''[[Qt:Документация 4.3.2/qhttp#ConnectionMode-enum | ConnectionMode]]''' { ConnectionModeHttp, ConnectionModeHttps }<br />
*enum '''[[Qt:Документация 4.3.2/qhttp#Error-enum | Error]]''' { NoError, HostNotFound, ConnectionRefused, UnexpectedClose, ..., UnknownError }<br />
*enum '''[[Qt:Документация 4.3.2/qhttp#State-enum | State]]''' { Unconnected, HostLookup, Connecting, Sending, ..., Closing }<br />
<div id="public-functions"></div><br />
===Открытые функции===<br />
<br />
*'''[[Qt:Документация 4.3.2/qhttp#QHttp | QHttp]]''' ( QObject * ''parent'' = 0 )<br />
*'''[[Qt:Документация 4.3.2/qhttp#QHttp-2 | QHttp]]''' ( const QString &amp; ''hostName'', quint16 ''port'' = 80, QObject * ''parent'' = 0 )<br />
*'''[[Qt:Документация 4.3.2/qhttp#QHttp-3 | QHttp]]''' ( const QString &amp; ''hostName'', ConnectionMode ''mode'', quint16 ''port'' = 0, QObject * ''parent'' = 0 )<br />
*virtual '''[[Qt:Документация 4.3.2/qhttp#dtor.QHttp | ~QHttp]]''' ()<br />
*qint64 '''[[Qt:Документация 4.3.2/qhttp#bytesAvailable | bytesAvailable]]''' () const<br />
*void '''[[Qt:Документация 4.3.2/qhttp#clearPendingRequests | clearPendingRequests]]''' ()<br />
*int '''[[Qt:Документация 4.3.2/qhttp#close | close]]''' ()<br />
*QIODevice * '''[[Qt:Документация 4.3.2/qhttp#currentDestinationDevice | currentDestinationDevice]]''' () const<br />
*int '''[[Qt:Документация 4.3.2/qhttp#currentId | currentId]]''' () const<br />
*QHttpRequestHeader '''[[Qt:Документация 4.3.2/qhttp#currentRequest | currentRequest]]''' () const<br />
*QIODevice * '''[[Qt:Документация 4.3.2/qhttp#currentSourceDevice | currentSourceDevice]]''' () const<br />
*Error '''[[Qt:Документация 4.3.2/qhttp#error | error]]''' () const<br />
*QString '''[[Qt:Документация 4.3.2/qhttp#errorString | errorString]]''' () const<br />
*int '''[[Qt:Документация 4.3.2/qhttp#get | get]]''' ( const QString &amp; ''path'', QIODevice * ''to'' = 0 )<br />
*bool '''[[Qt:Документация 4.3.2/qhttp#hasPendingRequests | hasPendingRequests]]''' () const<br />
*int '''[[Qt:Документация 4.3.2/qhttp#head | head]]''' ( const QString &amp; ''path'' )<br />
*QHttpResponseHeader '''[[Qt:Документация 4.3.2/qhttp#lastResponse | lastResponse]]''' () const<br />
*int '''[[Qt:Документация 4.3.2/qhttp#post | post]]''' ( const QString &amp; ''path'', QIODevice * ''data'', QIODevice * ''to'' = 0 )<br />
*int '''[[Qt:Документация 4.3.2/qhttp#post-2 | post]]''' ( const QString &amp; ''path'', const QByteArray &amp; ''data'', QIODevice * ''to'' = 0 )<br />
*qint64 '''[[Qt:Документация 4.3.2/qhttp#read | read]]''' ( char * ''data'', qint64 ''maxlen'' )<br />
*QByteArray '''[[Qt:Документация 4.3.2/qhttp#readAll | readAll]]''' ()<br />
*int '''[[Qt:Документация 4.3.2/qhttp#request | request]]''' ( const QHttpRequestHeader &amp; ''header'', QIODevice * ''data'' = 0, QIODevice * ''to'' = 0 )<br />
*int '''[[Qt:Документация 4.3.2/qhttp#request-2 | request]]''' ( const QHttpRequestHeader &amp; ''header'', const QByteArray &amp; ''data'', QIODevice * ''to'' = 0 )<br />
*int '''[[Qt:Документация 4.3.2/qhttp#setHost | setHost]]''' ( const QString &amp; ''hostName'', quint16 ''port'' = 80 )<br />
*int '''[[Qt:Документация 4.3.2/qhttp#setHost-2 | setHost]]''' ( const QString &amp; ''hostName'', ConnectionMode ''mode'', quint16 ''port'' = 0 )<br />
*int '''[[Qt:Документация 4.3.2/qhttp#setProxy | setProxy]]''' ( const QString &amp; ''host'', int ''port'', const QString &amp; ''username'' = QString(), const QString &amp; ''password'' = QString() )<br />
*int '''[[Qt:Документация 4.3.2/qhttp#setProxy-2 | setProxy]]''' ( const QNetworkProxy &amp; ''proxy'' )<br />
*int '''[[Qt:Документация 4.3.2/qhttp#setSocket | setSocket]]''' ( QTcpSocket * ''socket'' )<br />
*int '''[[Qt:Документация 4.3.2/qhttp#setUser | setUser]]''' ( const QString &amp; ''userName'', const QString &amp; ''password'' = QString() )<br />
*State '''[[Qt:Документация 4.3.2/qhttp#state | state]]''' () const<br />
<br />
*29 открытых функций, унаследованных от [[Qt:Документация 4.3.2/qobject#public-functions | QObject]]<br />
<div id="public-slots"></div><br />
===Открытые слоты===<br />
<br />
*void '''[[Qt:Документация 4.3.2/qhttp#abort | abort]]''' ()<br />
*void '''[[Qt:Документация 4.3.2/qhttp#ignoreSslErrors | ignoreSslErrors]]''' ()<br />
<br />
*1 открытый слот, унаследованный от [[Qt:Документация 4.3.2/qobject#public-slots | QObject]]<br />
<div id="signals"></div><br />
===Сигналы===<br />
<br />
*void '''[[Qt:Документация 4.3.2/qhttp#authenticationRequired | authenticationRequired]]''' ( const QString &amp; ''hostname'', quint16 ''port'', QAuthenticator * ''authenticator'' )<br />
*void '''[[Qt:Документация 4.3.2/qhttp#dataReadProgress | dataReadProgress]]''' ( int ''done'', int ''total'' )<br />
*void '''[[Qt:Документация 4.3.2/qhttp#dataSendProgress | dataSendProgress]]''' ( int ''done'', int ''total'' )<br />
*void '''[[Qt:Документация 4.3.2/qhttp#done | done]]''' ( bool ''error'' )<br />
*void '''[[Qt:Документация 4.3.2/qhttp#proxyAuthenticationRequired | proxyAuthenticationRequired]]''' ( const QNetworkProxy &amp; ''proxy'', QAuthenticator * ''authenticator'' )<br />
*void '''[[Qt:Документация 4.3.2/qhttp#readyRead | readyRead]]''' ( const QHttpResponseHeader &amp; ''resp'' )<br />
*void '''[[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]''' ( int ''id'', bool ''error'' )<br />
*void '''[[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]]''' ( int ''id'' )<br />
*void '''[[Qt:Документация 4.3.2/qhttp#responseHeaderReceived | responseHeaderReceived]]''' ( const QHttpResponseHeader &amp; ''resp'' )<br />
*void '''[[Qt:Документация 4.3.2/qhttp#sslErrors | sslErrors]]''' ( const QList<QSslError> &amp; ''errors'' )<br />
*void '''[[Qt:Документация 4.3.2/qhttp#stateChanged | stateChanged]]''' ( int ''state'' )<br />
<br />
*1 сигнал, унаследованный от [[Qt:Документация 4.3.2/qobject#signals | QObject]]<br />
<br />
===Дополнительные унаследованные члены===<br />
<br />
*1 свойство, унаследованное от [[Qt:Документация 4.3.2/qobject#properties | QObject]]<br />
*5 статических открытых членов, унаследованных от [[Qt:Документация 4.3.2/qobject#static-public-members | QObject]]<br />
*7 защищенных функций, унаследованных от [[Qt:Документация 4.3.2/qobject#protected-functions | QObject]]<br />
<div id="details"></div><hr /><br />
==Подробное описание==<br />
<br />
The QHttp class provides an implementation of the HTTP protocol.<br />
<br />
This class provides a direct interface to HTTP that allows you to have more control over the requests and that allows you to access the response header fields.<br />
<br />
The class works asynchronously, so there are no blocking functions. If an operation cannot be executed immediately, the function will still return straight away and the operation will be scheduled for later execution. The results of scheduled operations are reported via signals. This approach depends on the event loop being in operation.<br />
<br />
The operations that can be scheduled (they are called "requests" in the rest of the documentation) are the following: [[Qt:Документация 4.3.2/qhttp#setHost | setHost]](), [[Qt:Документация 4.3.2/qhttp#get | get]](), [[Qt:Документация 4.3.2/qhttp#post | post]](), [[Qt:Документация 4.3.2/qhttp#head | head]]() and [[Qt:Документация 4.3.2/qhttp#request | request]]().<br />
<br />
All of these requests return a unique identifier that allows you to keep track of the request that is currently executed. When the execution of a request starts, the [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]]() signal with the identifier is emitted and when the request is finished, the [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]() signal is emitted with the identifier and a bool that indicates if the request finished with an error.<br />
<br />
To make an HTTP request you must set up suitable HTTP headers. The following example demonstrates, how to request the main HTML page from the Trolltech home page (i.e. the URL <tt>http://www.trolltech.com/index.html</tt>):<br />
<source lang="cpp-qt"> QHttpRequestHeader header("GET", "/index.html");<br />
header.setValue("Host", "www.trolltech.com");<br />
http->setHost("www.trolltech.com");<br />
http->request(header);</source> <br />
For the common HTTP requests <tt>GET</tt>, <tt>POST</tt> and <tt>HEAD</tt>, QHttp provides the convenience functions [[Qt:Документация 4.3.2/qhttp#get | get]](), [[Qt:Документация 4.3.2/qhttp#post | post]]() and [[Qt:Документация 4.3.2/qhttp#head | head]](). They already use a reasonable header and if you don't have to set special header fields, they are easier to use. The above example can also be written as:<br />
<source lang="cpp-qt"> http->setHost("www.trolltech.com"); // id == 1<br />
http->get("/index.html"); // id == 2</source> <br />
For this example the following sequence of signals is emitted (with small variations, depending on network traffic, etc.):<br />
<source lang="cpp-qt"> requestStarted(1)<br />
requestFinished(1, false)<br />
<br />
requestStarted(2)<br />
stateChanged(Connecting)<br />
stateChanged(Sending)<br />
dataSendProgress(77, 77)<br />
stateChanged(Reading)<br />
responseHeaderReceived(responseheader)<br />
dataReadProgress(5388, 0)<br />
readyRead(responseheader)<br />
dataReadProgress(18300, 0)<br />
readyRead(responseheader)<br />
stateChanged(Connected)<br />
requestFinished(2, false)<br />
<br />
done(false)<br />
<br />
stateChanged(Closing)<br />
stateChanged(Unconnected)</source> <br />
The [[Qt:Документация 4.3.2/qhttp#dataSendProgress | dataSendProgress]]() and [[Qt:Документация 4.3.2/qhttp#dataReadProgress | dataReadProgress]]() signals in the above example are useful if you want to show a [[Qt:Документация 4.3.2/qprogressbar | progress bar]] to inform the user about the progress of the download. The second argument is the total size of data. In certain cases it is not possible to know the total amount in advance, in which case the second argument is 0. (If you connect to a [[Qt:Документация 4.3.2/qprogressbar | QProgressBar]] a total of 0 results in a busy indicator.)<br />
<br />
When the response header is read, it is reported with the [[Qt:Документация 4.3.2/qhttp#responseHeaderReceived | responseHeaderReceived]]() signal.<br />
<br />
The [[Qt:Документация 4.3.2/qhttp#readyRead | readyRead]]() signal tells you that there is data ready to be read. The amount of data can then be queried with the [[Qt:Документация 4.3.2/qhttp#bytesAvailable | bytesAvailable]]() function and it can be read with the [[Qt:Документация 4.3.2/qhttp#read | read]]() or [[Qt:Документация 4.3.2/qhttp#readAll | readAll]]() functions.<br />
<br />
If an error occurs during the execution of one of the commands in a sequence of commands, all the pending commands (i.e. scheduled, but not yet executed commands) are cleared and no signals are emitted for them.<br />
<br />
For example, if you have the following sequence of requests<br />
<source lang="cpp-qt"> http->setHost("www.foo.bar"); // id == 1<br />
http->get("/index.html"); // id == 2<br />
http->post("register.html", data); // id == 3</source> <br />
and the [[Qt:Документация 4.3.2/qhttp#get | get]]() request fails because the host lookup fails, then the [[Qt:Документация 4.3.2/qhttp#post | post]]() request is never executed and the signals would look like this:<br />
<source lang="cpp-qt"> requestStarted(1)<br />
requestFinished(1, false)<br />
<br />
requestStarted(2)<br />
stateChanged(HostLookup)<br />
requestFinished(2, true)<br />
<br />
done(true)<br />
<br />
stateChanged(Unconnected)</source> <br />
You can then get details about the error with the [[Qt:Документация 4.3.2/qhttp#error | error]]() and [[Qt:Документация 4.3.2/qhttp#errorString | errorString]]() functions. Note that only unexpected behavior, like network failure is considered as an error. If the server response contains an error status, like a 404 response, this is reported as a normal response case. So you should always check the [[Qt:Документация 4.3.2/qhttpresponseheader#statusCode | status code]] of the response header.<br />
<br />
The functions [[Qt:Документация 4.3.2/qhttp#currentId | currentId]]() and [[Qt:Документация 4.3.2/qhttp#currentRequest | currentRequest]]() provide more information about the currently executing request.<br />
<br />
The functions [[Qt:Документация 4.3.2/qhttp#hasPendingRequests | hasPendingRequests]]() and [[Qt:Документация 4.3.2/qhttp#clearPendingRequests | clearPendingRequests]]() allow you to query and clear the list of pending requests.<br />
<br />
See also [[Qt:Документация 4.3.2/qftp | QFtp]], [[Qt:Документация 4.3.2/network-http | HTTP Example]], and [[Qt:Документация 4.3.2/network-torrent | Torrent Example]].<br />
<hr /><br />
==Описание типов==<br />
<br />
===<div id="ConnectionMode-enum"></div>enum QHttp::ConnectionMode===<br />
<br />
This enum is used to specify the mode of connection to use:<br />
<br />
<br />
{| border="1" cellpadding="2" cellspacing="1" width="100%"<br />
<br />
|-<br />
! width="25%" | Константа<br />
! width="15%" | Значение<br />
! width="60%" | Описание<br />
|-<br />
| valign="top" | <tt>QHttp::ConnectionModeHttp</tt><br />
| align="center" valign="top" | <tt>0</tt><br />
| valign="top" | The connection is a regular Http connection to the server<br />
|-<br />
| valign="top" | <tt>QHttp::ConnectionModeHttps</tt><br />
| align="center" valign="top" | <tt>1</tt><br />
| valign="top" | The Https protocol is used and the connection is encrypted using SSL.<br />
|}<br />
<br />
When using the Https mode, care should be taken to connect to the sslErrors signal, and handle possible Ssl errors.<br />
<br />
Данное перечисление было введено в Qt 4.3.<br />
<br />
See also [[Qt:Документация 4.3.2/qsslsocket | QSslSocket]].<br />
<br />
===<div id="Error-enum"></div>enum QHttp::Error===<br />
<br />
This enum identifies the error that occurred.<br />
<br />
<br />
{| border="1" cellpadding="2" cellspacing="1" width="100%"<br />
<br />
|-<br />
! width="25%" | Константа<br />
! width="15%" | Значение<br />
! width="60%" | Описание<br />
|-<br />
| valign="top" | <tt>QHttp::NoError</tt><br />
| align="center" valign="top" | <tt>0</tt><br />
| valign="top" | No error occurred.<br />
|-<br />
| valign="top" | <tt>QHttp::HostNotFound</tt><br />
| align="center" valign="top" | <tt>2</tt><br />
| valign="top" | The host name lookup failed.<br />
|-<br />
| valign="top" | <tt>QHttp::ConnectionRefused</tt><br />
| align="center" valign="top" | <tt>3</tt><br />
| valign="top" | The server refused the connection.<br />
|-<br />
| valign="top" | <tt>QHttp::UnexpectedClose</tt><br />
| align="center" valign="top" | <tt>4</tt><br />
| valign="top" | The server closed the connection unexpectedly.<br />
|-<br />
| valign="top" | <tt>QHttp::InvalidResponseHeader</tt><br />
| align="center" valign="top" | <tt>5</tt><br />
| valign="top" | The server sent an invalid response header.<br />
|-<br />
| valign="top" | <tt>QHttp::WrongContentLength</tt><br />
| align="center" valign="top" | <tt>6</tt><br />
| valign="top" | The client could not read the content correctly because an error with respect to the content length occurred.<br />
|-<br />
| valign="top" | <tt>QHttp::Aborted</tt><br />
| align="center" valign="top" | <tt>7</tt><br />
| valign="top" | The request was aborted with [[Qt:Документация 4.3.2/qhttp#abort | abort]]().<br />
|-<br />
| valign="top" | <tt>QHttp::ProxyAuthenticationRequiredError</tt><br />
| align="center" valign="top" | <tt>9</tt><br />
| valign="top" | [[Qt:Документация 4.3.2/qhttp | QHttp]] is using a proxy, and the proxy server requires authentication to establish a connection.<br />
|-<br />
| valign="top" | <tt>QHttp::AuthenticationRequiredError</tt><br />
| align="center" valign="top" | <tt>8</tt><br />
| valign="top" | The web server requires authentication to complete the request.<br />
|-<br />
| valign="top" | <tt>QHttp::UnknownError</tt><br />
| align="center" valign="top" | <tt>1</tt><br />
| valign="top" | An error other than those specified above occurred.<br />
|}<br />
<br />
Смотрие также [[Qt:Документация 4.3.2/qhttp#error | error]]().<br />
<br />
===<div id="State-enum"></div>enum QHttp::State===<br />
<br />
This enum is used to specify the state the client is in:<br />
<br />
<br />
{| border="1" cellpadding="2" cellspacing="1" width="100%"<br />
<br />
|-<br />
! width="25%" | Константа<br />
! width="15%" | Значение<br />
! width="60%" | Описание<br />
|-<br />
| valign="top" | <tt>QHttp::Unconnected</tt><br />
| align="center" valign="top" | <tt>0</tt><br />
| valign="top" | There is no connection to the host.<br />
|-<br />
| valign="top" | <tt>QHttp::HostLookup</tt><br />
| align="center" valign="top" | <tt>1</tt><br />
| valign="top" | A host name lookup is in progress.<br />
|-<br />
| valign="top" | <tt>QHttp::Connecting</tt><br />
| align="center" valign="top" | <tt>2</tt><br />
| valign="top" | An attempt to connect to the host is in progress.<br />
|-<br />
| valign="top" | <tt>QHttp::Sending</tt><br />
| align="center" valign="top" | <tt>3</tt><br />
| valign="top" | The client is sending its request to the server.<br />
|-<br />
| valign="top" | <tt>QHttp::Reading</tt><br />
| align="center" valign="top" | <tt>4</tt><br />
| valign="top" | The client's request has been sent and the client is reading the server's response.<br />
|-<br />
| valign="top" | <tt>QHttp::Connected</tt><br />
| align="center" valign="top" | <tt>5</tt><br />
| valign="top" | The connection to the host is open, but the client is neither sending a request, nor waiting for a response.<br />
|-<br />
| valign="top" | <tt>QHttp::Closing</tt><br />
| align="center" valign="top" | <tt>6</tt><br />
| valign="top" | The connection is closing down, but is not yet closed. (The state will be <tt>Unconnected</tt> when the connection is closed.)<br />
|}<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#stateChanged | stateChanged]]() and [[Qt:Документация 4.3.2/qhttp#state | state]]().<br />
<hr /><br />
==Описание функций-членов==<br />
<br />
===<div id="QHttp"></div>QHttp::QHttp ( [[Qt:Документация 4.3.2/qobject | QObject]] * ''parent'' = 0 )===<br />
<br />
Constructs a [[Qt:Документация 4.3.2/qhttp | QHttp]] object. The ''parent'' parameter is passed on to the [[Qt:Документация 4.3.2/qobject | QObject]] constructor.<br />
<br />
===<div id="QHttp-2"></div>QHttp::QHttp ( const [[Qt:Документация 4.3.2/qstring | QString]] &amp; ''hostName'', [[Qt:Документация 4.3.2/qtglobal#quint16-typedef | quint16]] ''port'' = 80, [[Qt:Документация 4.3.2/qobject | QObject]] * ''parent'' = 0 )===<br />
<br />
Constructs a [[Qt:Документация 4.3.2/qhttp | QHttp]] object. Subsequent requests are done by connecting to the server ''hostName'' on port ''port''.<br />
<br />
The ''parent'' parameter is passed on to the [[Qt:Документация 4.3.2/qobject | QObject]] constructor.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#setHost | setHost]]().<br />
<br />
===<div id="QHttp-3"></div>QHttp::QHttp ( const [[Qt:Документация 4.3.2/qstring | QString]] &amp; ''hostName'', [[Qt:Документация 4.3.2/qhttp#ConnectionMode-enum | ConnectionMode]] ''mode'', [[Qt:Документация 4.3.2/qtglobal#quint16-typedef | quint16]] ''port'' = 0, [[Qt:Документация 4.3.2/qobject | QObject]] * ''parent'' = 0 )===<br />
<br />
Constructs a [[Qt:Документация 4.3.2/qhttp | QHttp]] object. Subsequent requests are done by connecting to the server ''hostName'' on port ''port'' using the connection mode ''mode''.<br />
<br />
If port is 0, it will use the default port for the ''mode'' used (80 for Http and 443 for Https).<br />
<br />
The ''parent'' parameter is passed on to the [[Qt:Документация 4.3.2/qobject | QObject]] constructor.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#setHost | setHost]]().<br />
<br />
===<div id="dtor.QHttp"></div>QHttp::~QHttp () <tt> [virtual]</tt>===<br />
<br />
Destroys the [[Qt:Документация 4.3.2/qhttp | QHttp]] object. If there is an open connection, it is closed.<br />
<br />
===<div id="abort"></div>void QHttp::abort () <tt> [slot]</tt>===<br />
<br />
Aborts the current request and deletes all scheduled requests.<br />
<br />
For the current request, the [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]() signal with the <tt>error</tt> argument <tt>true</tt> is emitted. For all other requests that are affected by the abort(), no signals are emitted.<br />
<br />
Since this slot also deletes the scheduled requests, there are no requests left and the [[Qt:Документация 4.3.2/qhttp#done | done]]() signal is emitted (with the <tt>error</tt> argument <tt>true</tt>).<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#clearPendingRequests | clearPendingRequests]]().<br />
<br />
===<div id="authenticationRequired"></div>void QHttp::authenticationRequired ( const [[Qt:Документация 4.3.2/qstring | QString]] &amp; ''hostname'', [[Qt:Документация 4.3.2/qtglobal#quint16-typedef | quint16]] ''port'', [[Qt:Документация 4.3.2/qauthenticator | QAuthenticator]] * ''authenticator'' ) <tt> [signal]</tt>===<br />
<br />
This signal can be emitted when a web server on a given ''hostname'' and ''port'' requires authentication. The ''authenticator'' object can then be filled in with the required details to allow authentication and continue the connection.<br />
<br />
'''Примечание:''' невозможно использовать QueuedConnection для подключения к этому сигналу, так как соединение не удастся установить без заполнения информации для аутентификации при возвращении сигнала.<br />
<br />
Эта функция была введена в Qt 4.3.<br />
<br />
Смотрите также [[Qt:Документация 4.3.2/qauthenticator | QAuthenticator]] и [[Qt:Документация 4.3.2/qnetworkproxy | QNetworkProxy]].<br />
<br />
===<div id="bytesAvailable"></div>[[Qt:Документация 4.3.2/qtglobal#qint64-typedef | qint64]] QHttp::bytesAvailable () const===<br />
<br />
Returns the number of bytes that can be read from the response content at the moment.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#get | get]](), [[Qt:Документация 4.3.2/qhttp#post | post]](), [[Qt:Документация 4.3.2/qhttp#request | request]](), [[Qt:Документация 4.3.2/qhttp#readyRead | readyRead]](), [[Qt:Документация 4.3.2/qhttp#read | read]](), and [[Qt:Документация 4.3.2/qhttp#readAll | readAll]]().<br />
<br />
===<div id="clearPendingRequests"></div>void QHttp::clearPendingRequests ()===<br />
<br />
Deletes all pending requests from the list of scheduled requests. This does not affect the request that is being executed. If you want to stop this this as well, use [[Qt:Документация 4.3.2/qhttp#abort | abort]]().<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#hasPendingRequests | hasPendingRequests]]() and [[Qt:Документация 4.3.2/qhttp#abort | abort]]().<br />
<br />
===<div id="close"></div>int QHttp::close ()===<br />
<br />
Closes the connection; this is useful if you have a keep-alive connection and want to close it.<br />
<br />
For the requests issued with [[Qt:Документация 4.3.2/qhttp#get | get]](), [[Qt:Документация 4.3.2/qhttp#post | post]]() and [[Qt:Документация 4.3.2/qhttp#head | head]](), [[Qt:Документация 4.3.2/qhttp | QHttp]] sets the connection to be keep-alive. You can also do this using the header you pass to the [[Qt:Документация 4.3.2/qhttp#request | request]]() function. [[Qt:Документация 4.3.2/qhttp | QHttp]] only closes the connection to the HTTP server if the response header requires it to do so.<br />
<br />
The function does not block and returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]]() and [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]().<br />
<br />
When the request is started the [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]]() signal is emitted. When it is finished the [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]() signal is emitted.<br />
<br />
If you want to close the connection immediately, you have to use [[Qt:Документация 4.3.2/qhttp#abort | abort]]() instead.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#stateChanged | stateChanged]](), [[Qt:Документация 4.3.2/qhttp#abort | abort]](), [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]](), [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]](), and [[Qt:Документация 4.3.2/qhttp#done | done]]().<br />
<br />
===<div id="currentDestinationDevice"></div>[[Qt:Документация 4.3.2/qiodevice | QIODevice]] * QHttp::currentDestinationDevice () const===<br />
<br />
Returns the [[Qt:Документация 4.3.2/qiodevice | QIODevice]] pointer that is used as to store the data of the HTTP request being executed. If there is no current request or if the request does not store the data to an IO device, this function returns 0.<br />
<br />
This function can be used to delete the [[Qt:Документация 4.3.2/qiodevice | QIODevice]] in the slot connected to the [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]() signal.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#currentSourceDevice | currentSourceDevice]](), [[Qt:Документация 4.3.2/qhttp#get | get]](), [[Qt:Документация 4.3.2/qhttp#post | post]](), and [[Qt:Документация 4.3.2/qhttp#request | request]]().<br />
<br />
===<div id="currentId"></div>int QHttp::currentId () const===<br />
<br />
Returns the identifier of the HTTP request being executed or 0 if there is no request being executed (i.e. they've all finished).<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#currentRequest | currentRequest]]().<br />
<br />
===<div id="currentRequest"></div>[[Qt:Документация 4.3.2/qhttprequestheader | QHttpRequestHeader]] QHttp::currentRequest () const===<br />
<br />
Returns the request header of the HTTP request being executed. If the request is one issued by [[Qt:Документация 4.3.2/qhttp#setHost | setHost]]() or [[Qt:Документация 4.3.2/qhttp#close | close]](), it returns an invalid request header, i.e. [[Qt:Документация 4.3.2/qhttpheader#isValid | QHttpRequestHeader::isValid]]() returns false.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#currentId | currentId]]().<br />
<br />
===<div id="currentSourceDevice"></div>[[Qt:Документация 4.3.2/qiodevice | QIODevice]] * QHttp::currentSourceDevice () const===<br />
<br />
Returns the [[Qt:Документация 4.3.2/qiodevice | QIODevice]] pointer that is used as the data source of the HTTP request being executed. If there is no current request or if the request does not use an IO device as the data source, this function returns 0.<br />
<br />
This function can be used to delete the [[Qt:Документация 4.3.2/qiodevice | QIODevice]] in the slot connected to the [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]() signal.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#currentDestinationDevice | currentDestinationDevice]](), [[Qt:Документация 4.3.2/qhttp#post | post]](), and [[Qt:Документация 4.3.2/qhttp#request | request]]().<br />
<br />
===<div id="dataReadProgress"></div>void QHttp::dataReadProgress ( int ''done'', int ''total'' ) <tt> [signal]</tt>===<br />
<br />
This signal is emitted when this object reads data from a HTTP server to indicate the current progress of the download.<br />
<br />
''done'' is the amount of data that has already arrived and ''total'' is the total amount of data. It is possible that the total amount of data that should be transferred cannot be determined, in which case ''total'' is 0.(If you connect to a [[Qt:Документация 4.3.2/qprogressbar | QProgressBar]], the progress bar shows a busy indicator if the total is 0).<br />
<br />
'''Warning:''' ''done'' and ''total'' are not necessarily the size in bytes, since for large files these values might need to be "scaled" to avoid overflow.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#dataSendProgress | dataSendProgress]](), [[Qt:Документация 4.3.2/qhttp#get | get]](), [[Qt:Документация 4.3.2/qhttp#post | post]](), [[Qt:Документация 4.3.2/qhttp#request | request]](), and [[Qt:Документация 4.3.2/qprogressbar | QProgressBar]].<br />
<br />
===<div id="dataSendProgress"></div>void QHttp::dataSendProgress ( int ''done'', int ''total'' ) <tt> [signal]</tt>===<br />
<br />
This signal is emitted when this object sends data to a HTTP server to inform it about the progress of the upload.<br />
<br />
''done'' is the amount of data that has already arrived and ''total'' is the total amount of data. It is possible that the total amount of data that should be transferred cannot be determined, in which case ''total'' is 0.(If you connect to a [[Qt:Документация 4.3.2/qprogressbar | QProgressBar]], the progress bar shows a busy indicator if the total is 0).<br />
<br />
'''Warning:''' ''done'' and ''total'' are not necessarily the size in bytes, since for large files these values might need to be "scaled" to avoid overflow.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#dataReadProgress | dataReadProgress]](), [[Qt:Документация 4.3.2/qhttp#post | post]](), [[Qt:Документация 4.3.2/qhttp#request | request]](), and [[Qt:Документация 4.3.2/qprogressbar | QProgressBar]].<br />
<br />
===<div id="done"></div>void QHttp::done ( bool ''error'' ) <tt> [signal]</tt>===<br />
<br />
This signal is emitted when the last pending request has finished; (it is emitted after the last request's [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]() signal). ''error'' is true if an error occurred during the processing; otherwise ''error'' is false.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]](), [[Qt:Документация 4.3.2/qhttp#error | error]](), and [[Qt:Документация 4.3.2/qhttp#errorString | errorString]]().<br />
<br />
===<div id="error"></div>[[Qt:Документация 4.3.2/qhttp#Error-enum | Error]] QHttp::error () const===<br />
<br />
Returns the last error that occurred. This is useful to find out what happened when receiving a [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]() or a [[Qt:Документация 4.3.2/qhttp#done | done]]() signal with the <tt>error</tt> argument <tt>true</tt>.<br />
<br />
If you start a new request, the error status is reset to <tt>NoError</tt>.<br />
<br />
===<div id="errorString"></div>[[Qt:Документация 4.3.2/qstring | QString]] QHttp::errorString () const===<br />
<br />
Returns a human-readable description of the last error that occurred. This is useful to present a error message to the user when receiving a [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]() or a [[Qt:Документация 4.3.2/qhttp#done | done]]() signal with the <tt>error</tt> argument <tt>true</tt>.<br />
<br />
===<div id="get"></div>int QHttp::get ( const [[Qt:Документация 4.3.2/qstring | QString]] &amp; ''path'', [[Qt:Документация 4.3.2/qiodevice | QIODevice]] * ''to'' = 0 )===<br />
<br />
Sends a get request for ''path'' to the server set by [[Qt:Документация 4.3.2/qhttp#setHost | setHost]]() or as specified in the constructor.<br />
<br />
''path'' must be an absolute path like <tt>/index.html</tt> or an absolute URI like <tt>http://www.trolltech.com/index.html</tt>.<br />
<br />
If the IO device ''to'' is 0 the [[Qt:Документация 4.3.2/qhttp#readyRead | readyRead]]() signal is emitted every time new content data is available to read.<br />
<br />
If the IO device ''to'' is not 0, the content data of the response is written directly to the device. Make sure that the ''to'' pointer is valid for the duration of the operation (it is safe to delete it when the [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]() signal is emitted).<br />
<br />
The function does not block and returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]]() and [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]().<br />
<br />
When the request is started the [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]]() signal is emitted. When it is finished the [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]() signal is emitted.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#setHost | setHost]](), [[Qt:Документация 4.3.2/qhttp#post | post]](), [[Qt:Документация 4.3.2/qhttp#head | head]](), [[Qt:Документация 4.3.2/qhttp#request | request]](), [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]](), [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]](), and [[Qt:Документация 4.3.2/qhttp#done | done]]().<br />
<br />
===<div id="hasPendingRequests"></div>bool QHttp::hasPendingRequests () const===<br />
<br />
Returns true if there are any requests scheduled that have not yet been executed; otherwise returns false.<br />
<br />
The request that is being executed is ''not'' considered as a scheduled request.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#clearPendingRequests | clearPendingRequests]](), [[Qt:Документация 4.3.2/qhttp#currentId | currentId]](), and [[Qt:Документация 4.3.2/qhttp#currentRequest | currentRequest]]().<br />
<br />
===<div id="head"></div>int QHttp::head ( const [[Qt:Документация 4.3.2/qstring | QString]] &amp; ''path'' )===<br />
<br />
Sends a header request for ''path'' to the server set by [[Qt:Документация 4.3.2/qhttp#setHost | setHost]]() or as specified in the constructor.<br />
<br />
''path'' must be an absolute path like <tt>/index.html</tt> or an absolute URI like <tt>http://www.trolltech.com/index.html</tt>.<br />
<br />
The function does not block and returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]]() and [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]().<br />
<br />
When the request is started the [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]]() signal is emitted. When it is finished the [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]() signal is emitted.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#setHost | setHost]](), [[Qt:Документация 4.3.2/qhttp#get | get]](), [[Qt:Документация 4.3.2/qhttp#post | post]](), [[Qt:Документация 4.3.2/qhttp#request | request]](), [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]](), [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]](), and [[Qt:Документация 4.3.2/qhttp#done | done]]().<br />
<br />
===<div id="ignoreSslErrors"></div>void QHttp::ignoreSslErrors () <tt> [slot]</tt>===<br />
<br />
Tells the [[Qt:Документация 4.3.2/qsslsocket | QSslSocket]] used for the Http connection to ignore the errors reported in the [[Qt:Документация 4.3.2/qhttp#sslErrors | sslErrors]]() signal.<br />
<br />
Note that this function must be called from within a slot connected to the [[Qt:Документация 4.3.2/qhttp#sslErrors | sslErrors]]() signal to have any effect.<br />
<br />
See also [[Qt:Документация 4.3.2/qsslsocket | QSslSocket]] and [[Qt:Документация 4.3.2/qsslsocket#sslErrors | QSslSocket::sslErrors]]().<br />
<br />
===<div id="lastResponse"></div>[[Qt:Документация 4.3.2/qhttpresponseheader | QHttpResponseHeader]] QHttp::lastResponse () const===<br />
<br />
Returns the received response header of the most recently finished HTTP request. If no response has yet been received [[Qt:Документация 4.3.2/qhttpheader#isValid | QHttpResponseHeader::isValid]]() will return false.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#currentRequest | currentRequest]]().<br />
<br />
===<div id="post"></div>int QHttp::post ( const [[Qt:Документация 4.3.2/qstring | QString]] &amp; ''path'', [[Qt:Документация 4.3.2/qiodevice | QIODevice]] * ''data'', [[Qt:Документация 4.3.2/qiodevice | QIODevice]] * ''to'' = 0 )===<br />
<br />
Sends a post request for ''path'' to the server set by [[Qt:Документация 4.3.2/qhttp#setHost | setHost]]() or as specified in the constructor.<br />
<br />
''path'' must be an absolute path like <tt>/index.html</tt> or an absolute URI like <tt>http://www.trolltech.com/index.html</tt>.<br />
<br />
The incoming data comes via the ''data'' IO device.<br />
<br />
If the IO device ''to'' is 0 the [[Qt:Документация 4.3.2/qhttp#readyRead | readyRead]]() signal is emitted every time new content data is available to read.<br />
<br />
If the IO device ''to'' is not 0, the content data of the response is written directly to the device. Make sure that the ''to'' pointer is valid for the duration of the operation (it is safe to delete it when the [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]() signal is emitted).<br />
<br />
The function does not block and returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]]() and [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]().<br />
<br />
When the request is started the [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]]() signal is emitted. When it is finished the [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]() signal is emitted.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#setHost | setHost]](), [[Qt:Документация 4.3.2/qhttp#get | get]](), [[Qt:Документация 4.3.2/qhttp#head | head]](), [[Qt:Документация 4.3.2/qhttp#request | request]](), [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]](), [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]](), and [[Qt:Документация 4.3.2/qhttp#done | done]]().<br />
<br />
===<div id="post-2"></div>int QHttp::post ( const [[Qt:Документация 4.3.2/qstring | QString]] &amp; ''path'', const [[Qt:Документация 4.3.2/qbytearray | QByteArray]] &amp; ''data'', [[Qt:Документация 4.3.2/qiodevice | QIODevice]] * ''to'' = 0 )===<br />
<br />
Эта перегруженная функция предоставлена для удобства.<br />
<br />
''data'' is used as the content data of the HTTP request.<br />
<br />
===<div id="proxyAuthenticationRequired"></div>void QHttp::proxyAuthenticationRequired ( const [[Qt:Документация 4.3.2/qnetworkproxy | QNetworkProxy]] &amp; ''proxy'', [[Qt:Документация 4.3.2/qauthenticator | QAuthenticator]] * ''authenticator'' ) <tt> [signal]</tt>===<br />
<br />
Этот сигнал посылается, когда используется прокси ''proxy'', требующий аутентификации. Объект ''authenticator'' может быть заполнен необходимыми сведениями для продолжения соединения.<br />
<br />
'''Примечание:''' невозможно использовать QueuedConnection для подключения к этому сигналу, так как соединение не удастся установить без заполнения информации для аутентификации при возвращении сигнала.<br />
<br />
Эта функция была введена в Qt 4.3.<br />
<br />
Смотрите также [[Qt:Документация 4.3.2/qauthenticator | QAuthenticator]] и [[Qt:Документация 4.3.2/qnetworkproxy | QNetworkProxy]].<br />
<br />
===<div id="read"></div>[[Qt:Документация 4.3.2/qtglobal#qint64-typedef | qint64]] QHttp::read ( char * ''data'', [[Qt:Документация 4.3.2/qtglobal#qint64-typedef | qint64]] ''maxlen'' )===<br />
<br />
Reads ''maxlen'' bytes from the response content into ''data'' and returns the number of bytes read. Returns -1 if an error occurred.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#get | get]](), [[Qt:Документация 4.3.2/qhttp#post | post]](), [[Qt:Документация 4.3.2/qhttp#request | request]](), [[Qt:Документация 4.3.2/qhttp#readyRead | readyRead]](), [[Qt:Документация 4.3.2/qhttp#bytesAvailable | bytesAvailable]](), and [[Qt:Документация 4.3.2/qhttp#readAll | readAll]]().<br />
<br />
===<div id="readAll"></div>[[Qt:Документация 4.3.2/qbytearray | QByteArray]] QHttp::readAll ()===<br />
<br />
Reads all the bytes from the response content and returns them.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#get | get]](), [[Qt:Документация 4.3.2/qhttp#post | post]](), [[Qt:Документация 4.3.2/qhttp#request | request]](), [[Qt:Документация 4.3.2/qhttp#readyRead | readyRead]](), [[Qt:Документация 4.3.2/qhttp#bytesAvailable | bytesAvailable]](), and [[Qt:Документация 4.3.2/qhttp#read | read]]().<br />
<br />
===<div id="readyRead"></div>void QHttp::readyRead ( const [[Qt:Документация 4.3.2/qhttpresponseheader | QHttpResponseHeader]] &amp; ''resp'' ) <tt> [signal]</tt>===<br />
<br />
This signal is emitted when there is new response data to read.<br />
<br />
If you specified a device in the request where the data should be written to, then this signal is ''not'' emitted; instead the data is written directly to the device.<br />
<br />
The response header is passed in ''resp''.<br />
<br />
You can read the data with the [[Qt:Документация 4.3.2/qhttp#readAll | readAll]]() or [[Qt:Документация 4.3.2/qhttp#read | read]]() functions<br />
<br />
This signal is useful if you want to process the data in chunks as soon as it becomes available. If you are only interested in the complete data, just connect to the [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]() signal and read the data then instead.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#get | get]](), [[Qt:Документация 4.3.2/qhttp#post | post]](), [[Qt:Документация 4.3.2/qhttp#request | request]](), [[Qt:Документация 4.3.2/qhttp#readAll | readAll]](), [[Qt:Документация 4.3.2/qhttp#read | read]](), and [[Qt:Документация 4.3.2/qhttp#bytesAvailable | bytesAvailable]]().<br />
<br />
===<div id="request"></div>int QHttp::request ( const [[Qt:Документация 4.3.2/qhttprequestheader | QHttpRequestHeader]] &amp; ''header'', [[Qt:Документация 4.3.2/qiodevice | QIODevice]] * ''data'' = 0, [[Qt:Документация 4.3.2/qiodevice | QIODevice]] * ''to'' = 0 )===<br />
<br />
Sends a request to the server set by [[Qt:Документация 4.3.2/qhttp#setHost | setHost]]() or as specified in the constructor. Uses the ''header'' as the HTTP request header. You are responsible for setting up a header that is appropriate for your request.<br />
<br />
The incoming data comes via the ''data'' IO device.<br />
<br />
If the IO device ''to'' is 0 the [[Qt:Документация 4.3.2/qhttp#readyRead | readyRead]]() signal is emitted every time new content data is available to read.<br />
<br />
If the IO device ''to'' is not 0, the content data of the response is written directly to the device. Make sure that the ''to'' pointer is valid for the duration of the operation (it is safe to delete it when the [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]() signal is emitted).<br />
<br />
The function does not block and returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]]() and [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]().<br />
<br />
When the request is started the [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]]() signal is emitted. When it is finished the [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]() signal is emitted.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#setHost | setHost]](), [[Qt:Документация 4.3.2/qhttp#get | get]](), [[Qt:Документация 4.3.2/qhttp#post | post]](), [[Qt:Документация 4.3.2/qhttp#head | head]](), [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]](), [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]](), and [[Qt:Документация 4.3.2/qhttp#done | done]]().<br />
<br />
===<div id="request-2"></div>int QHttp::request ( const [[Qt:Документация 4.3.2/qhttprequestheader | QHttpRequestHeader]] &amp; ''header'', const [[Qt:Документация 4.3.2/qbytearray | QByteArray]] &amp; ''data'', [[Qt:Документация 4.3.2/qiodevice | QIODevice]] * ''to'' = 0 )===<br />
<br />
Эта перегруженная функция предоставлена для удобства.<br />
<br />
''data'' is used as the content data of the HTTP request.<br />
<br />
===<div id="requestFinished"></div>void QHttp::requestFinished ( int ''id'', bool ''error'' ) <tt> [signal]</tt>===<br />
<br />
This signal is emitted when processing the request identified by ''id'' has finished. ''error'' is true if an error occurred during the processing; otherwise ''error'' is false.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]](), [[Qt:Документация 4.3.2/qhttp#done | done]](), [[Qt:Документация 4.3.2/qhttp#error | error]](), and [[Qt:Документация 4.3.2/qhttp#errorString | errorString]]().<br />
<br />
===<div id="requestStarted"></div>void QHttp::requestStarted ( int ''id'' ) <tt> [signal]</tt>===<br />
<br />
This signal is emitted when processing the request identified by ''id'' starts.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]() and [[Qt:Документация 4.3.2/qhttp#done | done]]().<br />
<br />
===<div id="responseHeaderReceived"></div>void QHttp::responseHeaderReceived ( const [[Qt:Документация 4.3.2/qhttpresponseheader | QHttpResponseHeader]] &amp; ''resp'' ) <tt> [signal]</tt>===<br />
<br />
This signal is emitted when the HTTP header of a server response is available. The header is passed in ''resp''.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#get | get]](), [[Qt:Документация 4.3.2/qhttp#post | post]](), [[Qt:Документация 4.3.2/qhttp#head | head]](), [[Qt:Документация 4.3.2/qhttp#request | request]](), and [[Qt:Документация 4.3.2/qhttp#readyRead | readyRead]]().<br />
<br />
===<div id="setHost"></div>int QHttp::setHost ( const [[Qt:Документация 4.3.2/qstring | QString]] &amp; ''hostName'', [[Qt:Документация 4.3.2/qtglobal#quint16-typedef | quint16]] ''port'' = 80 )===<br />
<br />
Sets the HTTP server that is used for requests to ''hostName'' on port ''port''.<br />
<br />
The function does not block and returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]]() and [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]().<br />
<br />
When the request is started the [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]]() signal is emitted. When it is finished the [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]() signal is emitted.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#get | get]](), [[Qt:Документация 4.3.2/qhttp#post | post]](), [[Qt:Документация 4.3.2/qhttp#head | head]](), [[Qt:Документация 4.3.2/qhttp#request | request]](), [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]](), [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]](), and [[Qt:Документация 4.3.2/qhttp#done | done]]().<br />
<br />
===<div id="setHost-2"></div>int QHttp::setHost ( const [[Qt:Документация 4.3.2/qstring | QString]] &amp; ''hostName'', [[Qt:Документация 4.3.2/qhttp#ConnectionMode-enum | ConnectionMode]] ''mode'', [[Qt:Документация 4.3.2/qtglobal#quint16-typedef | quint16]] ''port'' = 0 )===<br />
<br />
Эта перегруженная функция предоставлена для удобства.<br />
<br />
Sets the HTTP server that is used for requests to ''hostName'' on port ''port'' using the connection mode ''mode''.<br />
<br />
If port is 0, it will use the default port for the ''mode'' used (80 for Http and 443 fopr Https).<br />
<br />
The function does not block and returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]]() and [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]().<br />
<br />
When the request is started the [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]]() signal is emitted. When it is finished the [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]() signal is emitted.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#get | get]](), [[Qt:Документация 4.3.2/qhttp#post | post]](), [[Qt:Документация 4.3.2/qhttp#head | head]](), [[Qt:Документация 4.3.2/qhttp#request | request]](), [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]](), [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]](), and [[Qt:Документация 4.3.2/qhttp#done | done]]().<br />
<br />
===<div id="setProxy"></div>int QHttp::setProxy ( const [[Qt:Документация 4.3.2/qstring | QString]] &amp; ''host'', int ''port'', const [[Qt:Документация 4.3.2/qstring | QString]] &amp; ''username'' = QString(), const [[Qt:Документация 4.3.2/qstring | QString]] &amp; ''password'' = QString() )===<br />
<br />
Enables HTTP proxy support, using the proxy server ''host'' on port ''port''. ''username'' and ''password'' can be provided if the proxy server requires authentication.<br />
<br />
Пример:<br />
<source lang="cpp-qt"> void Ticker::getTicks()<br />
{<br />
http = new QHttp(this);<br />
connect(http, SIGNAL(done(bool)), this, SLOT(showPage()));<br />
http->setProxy("proxy.example.com", 3128);<br />
http->setHost("ticker.example.com");<br />
http->get("/ticks.asp");<br />
}<br />
<br />
void Ticker::showPage()<br />
{<br />
display(http->readAll());<br />
}</source> <br />
[[Qt:Документация 4.3.2/qhttp | QHttp]] supports non-transparent web proxy servers only, such as the Squid Web proxy cache server (from [http://www.squid.org/ http://www.squid.org/]). For transparent proxying, such as SOCKS5, use [[Qt:Документация 4.3.2/qnetworkproxy | QNetworkProxy]] instead.<br />
<br />
See also [[Qt:Документация 4.3.2/qftp#setProxy | QFtp::setProxy]]().<br />
<br />
===<div id="setProxy-2"></div>int QHttp::setProxy ( const [[Qt:Документация 4.3.2/qnetworkproxy | QNetworkProxy]] &amp; ''proxy'' )===<br />
<br />
Эта перегруженная функция предоставлена для удобства.<br />
<br />
Enables HTTP proxy support using the proxy settings from ''proxy''.<br />
<br />
===<div id="setSocket"></div>int QHttp::setSocket ( [[Qt:Документация 4.3.2/qtcpsocket | QTcpSocket]] * ''socket'' )===<br />
<br />
Replaces the internal [[Qt:Документация 4.3.2/qtcpsocket | QTcpSocket]] that [[Qt:Документация 4.3.2/qhttp | QHttp]] uses with ''socket''. This is useful if you want to use your own custom [[Qt:Документация 4.3.2/qtcpsocket | QTcpSocket]] subclass instead of the plain [[Qt:Документация 4.3.2/qtcpsocket | QTcpSocket]] that [[Qt:Документация 4.3.2/qhttp | QHttp]] uses by default. [[Qt:Документация 4.3.2/qhttp | QHttp]] does not take ownership of the socket, and will not delete ''socket'' when destroyed.<br />
<br />
The function does not block and returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]]() and [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]().<br />
<br />
When the request is started the [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]]() signal is emitted. When it is finished the [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]() signal is emitted.<br />
<br />
Note: If [[Qt:Документация 4.3.2/qhttp | QHttp]] is used in a non-GUI thread that runs its own event loop, you must move ''socket'' to that thread before calling setSocket().<br />
<br />
See also [[Qt:Документация 4.3.2/qobject#moveToThread | QObject::moveToThread]]() and [[Qt:Документация 4.3.2/threads | Thread Support in Qt]].<br />
<br />
===<div id="setUser"></div>int QHttp::setUser ( const [[Qt:Документация 4.3.2/qstring | QString]] &amp; ''userName'', const [[Qt:Документация 4.3.2/qstring | QString]] &amp; ''password'' = QString() )===<br />
<br />
This function sets the user name ''userName'' and password ''password'' for web pages that require authentication.<br />
<br />
The function does not block and returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]]() and [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]().<br />
<br />
When the request is started the [[Qt:Документация 4.3.2/qhttp#requestStarted | requestStarted]]() signal is emitted. When it is finished the [[Qt:Документация 4.3.2/qhttp#requestFinished | requestFinished]]() signal is emitted.<br />
<br />
===<div id="sslErrors"></div>void QHttp::sslErrors ( const [[Qt:Документация 4.3.2/qlist | QList]]<[[Qt:Документация 4.3.2/qsslerror | QSslError]]> &amp; ''errors'' ) <tt> [signal]</tt>===<br />
<br />
Forwards the sslErrors signal from the [[Qt:Документация 4.3.2/qsslsocket | QSslSocket]] used in [[Qt:Документация 4.3.2/qhttp | QHttp]]. ''errors'' is the list of errors that occurred during the SSL handshake. Unless you call [[Qt:Документация 4.3.2/qhttp#ignoreSslErrors | ignoreSslErrors]]() from within a slot connected to this signal when an error occurs, [[Qt:Документация 4.3.2/qhttp | QHttp]] will tear down the connection immediately after emitting the signal.<br />
<br />
Эта функция была введена в Qt 4.3.<br />
<br />
See also [[Qt:Документация 4.3.2/qsslsocket | QSslSocket]] and [[Qt:Документация 4.3.2/qsslsocket#ignoreSslErrors | QSslSocket::ignoreSslErrors]]().<br />
<br />
===<div id="state"></div>[[Qt:Документация 4.3.2/qhttp#State-enum | State]] QHttp::state () const===<br />
<br />
Returns the current state of the object. When the state changes, the [[Qt:Документация 4.3.2/qhttp#stateChanged | stateChanged]]() signal is emitted.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#State-enum | State]] and [[Qt:Документация 4.3.2/qhttp#stateChanged | stateChanged]]().<br />
<br />
===<div id="stateChanged"></div>void QHttp::stateChanged ( int ''state'' ) <tt> [signal]</tt>===<br />
<br />
This signal is emitted when the state of the [[Qt:Документация 4.3.2/qhttp | QHttp]] object changes. The argument ''state'' is the new state of the connection; it is one of the [[Qt:Документация 4.3.2/qhttp#State-enum | State]] values.<br />
<br />
This usually happens when a request is started, but it can also happen when the server closes the connection or when a call to [[Qt:Документация 4.3.2/qhttp#close | close]]() succeeded.<br />
<br />
See also [[Qt:Документация 4.3.2/qhttp#get | get]](), [[Qt:Документация 4.3.2/qhttp#post | post]](), [[Qt:Документация 4.3.2/qhttp#head | head]](), [[Qt:Документация 4.3.2/qhttp#request | request]](), [[Qt:Документация 4.3.2/qhttp#close | close]](), [[Qt:Документация 4.3.2/qhttp#state | state]](), and [[Qt:Документация 4.3.2/qhttp#State-enum | State]].<br />
<br />
<br />
{{Qt4.3.2_footer}}</div>Root