QHttp Class

The QHttp class provides an implementation of the HTTP protocol. 更多...

头: #include <QHttp>
继承: QObject

该类已过时。 提供它是为使旧源代码能继续工作。强烈建议不要在新代码中使用它。

注意: 此类的所有函数 可重入 .

公共类型

enum ConnectionMode { ConnectionModeHttp, ConnectionModeHttps }
enum Error { NoError, HostNotFound, ConnectionRefused, UnexpectedClose, ..., UnknownError }
enum State { Unconnected, HostLookup, Connecting, Sending, ..., Closing }

公共函数

QHttp (QObject * parent = 0)
QHttp (const QString & hostName , quint16 port = 80, QObject * parent = 0)
QHttp (const QString & hostName , ConnectionMode mode , quint16 port = 0, QObject * parent = 0)
virtual ~QHttp ()
qint64 bytesAvailable () const
void clearPendingRequests ()
int close ()
QIODevice * currentDestinationDevice () const
int currentId () const
QHttpRequestHeader currentRequest () const
QIODevice * currentSourceDevice () const
Error error () const
QString errorString () const
int get (const QString & path , QIODevice * to = 0)
bool hasPendingRequests () const
int head (const QString & path )
QHttpResponseHeader lastResponse () const
int post (const QString & path , QIODevice * data , QIODevice * to = 0)
int post (const QString & path , const QByteArray & data , QIODevice * to = 0)
qint64 read (char * data , qint64 maxlen )
QByteArray readAll ()
int request (const QHttpRequestHeader & header , QIODevice * data = 0, QIODevice * to = 0)
int request (const QHttpRequestHeader & header , const QByteArray & data , QIODevice * to = 0)
int setHost (const QString & hostName , quint16 port = 80)
int setHost (const QString & hostName , ConnectionMode mode , quint16 port = 0)
int setProxy (const QString & host , int port , const QString & username = QString(), const QString & password = QString())
int setProxy (const QNetworkProxy & proxy )
int setSocket (QTcpSocket * socket )
int setUser (const QString & userName , const QString & password = QString())
状态 state () const

公共槽

void abort ()
void ignoreSslErrors ()

信号

void authenticationRequired (const QString & hostname , quint16 port , QAuthenticator * authenticator )
void dataReadProgress (int done , int total )
void dataSendProgress (int done , int total )
void done (bool error )
void proxyAuthenticationRequired (const QNetworkProxy & proxy , QAuthenticator * authenticator )
void readyRead (const QHttpResponseHeader & resp )
void requestFinished (int id , bool error )
void requestStarted (int id )
void responseHeaderReceived (const QHttpResponseHeader & resp )
void sslErrors (const QList<QSslError> & errors )
void stateChanged (int state )

额外继承成员

详细描述

The QHttp class provides an implementation of the HTTP protocol.

This class provides a direct interface to HTTP that allows you to download and upload data with the HTTP protocol. However, for new applications, it is recommended to use QNetworkAccessManager and QNetworkReply , as those classes possess a simpler, yet more powerful API and a more modern protocol implementation.

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.

The operations that can be scheduled (they are called "requests" in the rest of the documentation) are the following: setHost (), get (), post (), head () 和 request ().

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 requestStarted () signal with the identifier is emitted and when the request is finished, the requestFinished () signal is emitted with the identifier and a bool that indicates if the request finished with an error.

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 Qt website (i.e., the URL http://www.qt.io ):

QHttpRequestHeader header("GET", QUrl::toPercentEncoding("/index.html"));
header.setValue("Host", "qt.nokia.com");
http->setHost("qt.nokia.com");
http->request(header);
					

For the common HTTP requests GET , POST and HEAD , QHttp provides the convenience functions get (), post () 和 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:

http->setHost("qt.nokia.com");                // id == 1
http->get(QUrl::toPercentEncoding("/index.html")); // id == 2
					

For this example the following sequence of signals is emitted (with small variations, depending on network traffic, etc.):

requestStarted(1)
requestFinished(1, false)
requestStarted(2)
stateChanged(Connecting)
stateChanged(Sending)
dataSendProgress(77, 77)
stateChanged(Reading)
responseHeaderReceived(responseheader)
dataReadProgress(5388, 0)
readyRead(responseheader)
dataReadProgress(18300, 0)
readyRead(responseheader)
stateChanged(Connected)
requestFinished(2, false)
done(false)
stateChanged(Closing)
stateChanged(Unconnected)
					

The dataSendProgress () 和 dataReadProgress () signals in the above example are useful if you want to show a 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 QProgressBar a total of 0 results in a busy indicator.)

When the response header is read, it is reported with the responseHeaderReceived () 信号。

The readyRead () signal tells you that there is data ready to be read. The amount of data can then be queried with the bytesAvailable () function and it can be read with the read () 或 readAll () 函数。

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.

For example, if you have the following sequence of requests

http->setHost("www.foo.bar");       // id == 1
http->get("/index.html");           // id == 2
http->post("register.html", data);  // id == 3
					

get () request fails because the host lookup fails, then the post () request is never executed and the signals would look like this:

requestStarted(1)
requestFinished(1, false)
requestStarted(2)
stateChanged(HostLookup)
requestFinished(2, true)
done(true)
stateChanged(Unconnected)
					

You can then get details about the error with the error () 和 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 status code of the response header.

函数 currentId () 和 currentRequest () provide more information about the currently executing request.

函数 hasPendingRequests () 和 clearPendingRequests () allow you to query and clear the list of pending requests.

另请参阅 QFtp , QNetworkAccessManager , QNetworkRequest , QNetworkReply , HTTP 范例 ,和 Torrent 范例 .

成员类型文档编制

enum QHttp:: ConnectionMode

This enum is used to specify the mode of connection to use:

常量 描述
QHttp::ConnectionModeHttp 0 The connection is a regular HTTP connection to the server
QHttp::ConnectionModeHttps 1 The HTTPS protocol is used and the connection is encrypted using SSL.

When using the HTTPS mode, care should be taken to connect to the sslErrors signal, and handle possible SSL errors.

该枚举在 Qt 4.3 引入或被修改。

另请参阅 QSslSocket .

enum QHttp:: Error

This enum identifies the error that occurred.

常量 描述
QHttp::NoError 0 没有出现错误。
QHttp::HostNotFound 2 The host name lookup failed.
QHttp::ConnectionRefused 3 The server refused the connection.
QHttp::UnexpectedClose 4 The server closed the connection unexpectedly.
QHttp::InvalidResponseHeader 5 The server sent an invalid response header.
QHttp::WrongContentLength 6 The client could not read the content correctly because an error with respect to the content length occurred.
QHttp::Aborted 7 The request was aborted with abort ().
QHttp::ProxyAuthenticationRequiredError 9 QHttp is using a proxy, and the proxy server requires authentication to establish a connection.
QHttp::AuthenticationRequiredError 8 The web server requires authentication to complete the request.
QHttp::UnknownError 1 An error other than those specified above occurred.

另请参阅 error ().

enum QHttp:: State

This enum is used to specify the state the client is in:

常量 描述
QHttp::Unconnected 0 There is no connection to the host.
QHttp::HostLookup 1 A host name lookup is in progress.
QHttp::Connecting 2 An attempt to connect to the host is in progress.
QHttp::Sending 3 The client is sending its request to the server.
QHttp::Reading 4 The client's request has been sent and the client is reading the server's response.
QHttp::Connected 5 The connection to the host is open, but the client is neither sending a request, nor waiting for a response.
QHttp::Closing 6 The connection is closing down, but is not yet closed. (The state will be Unconnected when the connection is closed.)

另请参阅 stateChanged () 和 state ().

成员函数文档编制

QHttp:: QHttp ( QObject * parent = 0)

构造 QHttp 对象。 parent 参数被传递给 QObject 构造函数。

QHttp:: QHttp (const QString & hostName , quint16 port = 80, QObject * parent = 0)

构造 QHttp object. Subsequent requests are done by connecting to the server hostName 在端口 port .

The parent 参数被传递给 QObject 构造函数。

另请参阅 setHost ().

QHttp:: QHttp (const QString & hostName , ConnectionMode mode , quint16 port = 0, QObject * parent = 0)

构造 QHttp object. Subsequent requests are done by connecting to the server hostName 在端口 port using the connection mode mode .

If port is 0, it will use the default port for the mode used (80 for Http and 443 for Https).

The parent 参数被传递给 QObject 构造函数。

另请参阅 setHost ().

[虚拟] QHttp:: ~QHttp ()

销毁 QHttp object. If there is an open connection, it is closed.

[slot] void QHttp:: abort ()

Aborts the current request and deletes all scheduled requests.

For the current request, the requestFinished () 信号采用 error argument true is emitted. For all other requests that are affected by the abort(), no signals are emitted.

Since this slot also deletes the scheduled requests, there are no requests left and the done () signal is emitted (with the error argument true ).

另请参阅 clearPendingRequests ().

[signal] void QHttp:: authenticationRequired (const QString & hostname , quint16 port , QAuthenticator * authenticator )

This signal can be emitted when a web server on a given hostname and port requires authentication. The authenticator 然后可以采用所需的详细信息填充对象,以允许身份验证并继续连接。

注意: 使用 QueuedConnection 去连接到此信号是不可能的,因为连接会失败,若身份验证器没有采新信息被填充,当信号返回时。

该函数在 Qt 4.3 引入。

另请参阅 QAuthenticator and QNetworkProxy .

qint64 QHttp:: bytesAvailable () const

Returns the number of bytes that can be read from the response content at the moment.

另请参阅 get (), post (), request (), readyRead (), read (),和 readAll ().

void QHttp:: clearPendingRequests ()

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 as well, use abort ().

另请参阅 hasPendingRequests () 和 abort ().

int QHttp:: close ()

Closes the connection; this is useful if you have a keep-alive connection and want to close it.

For the requests issued with get (), post () 和 head (), QHttp sets the connection to be keep-alive. You can also do this using the header you pass to the request () 函数。 QHttp only closes the connection to the HTTP server if the response header requires it to do so.

The function does not block; instead, it returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by requestStarted () 和 requestFinished ().

When the request is started the requestStarted () signal is emitted. When it is finished the requestFinished () 信号发射。

If you want to close the connection immediately, you have to use abort () 代替。

另请参阅 stateChanged (), abort (), requestStarted (), requestFinished (),和 done ().

QIODevice * QHttp:: currentDestinationDevice () const

返回 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.

This function can be used to delete the QIODevice in the slot connected to the requestFinished () 信号。

另请参阅 currentSourceDevice (), get (), post (),和 request ().

int QHttp:: currentId () const

Returns the identifier of the HTTP request being executed or 0 if there is no request being executed (i.e. they've all finished).

另请参阅 currentRequest ().

QHttpRequestHeader QHttp:: currentRequest () const

Returns the request header of the HTTP request being executed. If the request is one issued by setHost () 或 close (), it returns an invalid request header, i.e. QHttpRequestHeader::isValid () 返回 false。

另请参阅 currentId ().

QIODevice * QHttp:: currentSourceDevice () const

返回 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.

This function can be used to delete the QIODevice in the slot connected to the requestFinished () 信号。

另请参阅 currentDestinationDevice (), post (),和 request ().

[signal] void QHttp:: dataReadProgress ( int done , int total )

This signal is emitted when this object reads data from a HTTP server to indicate the current progress of the download.

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 QProgressBar , the progress bar shows a busy indicator if the total is 0).

警告: done and total are not necessarily the size in bytes, since for large files these values might need to be "scaled" to avoid overflow.

另请参阅 dataSendProgress (), get (), post (), request (),和 QProgressBar .

[signal] void QHttp:: dataSendProgress ( int done , int total )

This signal is emitted when this object sends data to a HTTP server to inform it about the progress of the upload.

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 QProgressBar , the progress bar shows a busy indicator if the total is 0).

警告: done and total are not necessarily the size in bytes, since for large files these values might need to be "scaled" to avoid overflow.

另请参阅 dataReadProgress (), post (), request (),和 QProgressBar .

[signal] void QHttp:: done ( bool error )

This signal is emitted when the last pending request has finished; (it is emitted after the last request's requestFinished () signal). error is true if an error occurred during the processing; otherwise error 为 false。

另请参阅 requestFinished (), error (),和 errorString ().

Error QHttp:: error () const

Returns the last error that occurred. This is useful to find out what happened when receiving a requestFinished () or a done () 信号采用 error argument true .

If you start a new request, the error status is reset to NoError .

QString QHttp:: errorString () const

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 requestFinished () or a done () 信号采用 error argument true .

int QHttp:: get (const QString & path , QIODevice * to = 0)

Sends a get request for path to the server set by setHost () or as specified in the constructor.

path must be a absolute path like /index.html or an absolute URI like http://example.com/index.html and must be encoded with either QUrl::toPercentEncoding () 或 QUrl::encodedPath ().

If the IO device to is 0 the readyRead () signal is emitted every time new content data is available to read.

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 requestFinished () signal is emitted).

Request Processing

The function does not block; instead, it returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by requestStarted () 和 requestFinished ().

When the request is started the requestStarted () signal is emitted. When it is finished the requestFinished () 信号发射。

另请参阅 setHost (), post (), head (), request (), requestStarted (), requestFinished (),和 done ().

bool QHttp:: hasPendingRequests () const

Returns true if there are any requests scheduled that have not yet been executed; otherwise returns false.

The request that is being executed is not considered as a scheduled request.

另请参阅 clearPendingRequests (), currentId (),和 currentRequest ().

Sends a header request for path to the server set by setHost () or as specified in the constructor.

path must be an absolute path like /index.html or an absolute URI like http://example.com/index.html .

The function does not block; instead, it returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by requestStarted () 和 requestFinished ().

When the request is started the requestStarted () signal is emitted. When it is finished the requestFinished () 信号发射。

另请参阅 setHost (), get (), post (), request (), requestStarted (), requestFinished (),和 done ().

[slot] void QHttp:: ignoreSslErrors ()

Tells the QSslSocket used for the Http connection to ignore the errors reported in the sslErrors () 信号。

Note that this function must be called from within a slot connected to the sslErrors () signal to have any effect.

另请参阅 QSslSocket and QSslSocket::sslErrors ().

QHttpResponseHeader QHttp:: lastResponse () const

Returns the received response header of the most recently finished HTTP request. If no response has yet been received QHttpResponseHeader::isValid () 将返回 false。

另请参阅 currentRequest ().

int QHttp:: post (const QString & path , QIODevice * data , QIODevice * to = 0)

Sends a post request for path to the server set by setHost () or as specified in the constructor.

path must be an absolute path like /index.html or an absolute URI like http://example.com/index.html and must be encoded with either QUrl::toPercentEncoding () 或 QUrl::encodedPath ().

The incoming data comes via the data IO device.

If the IO device to is 0 the readyRead () signal is emitted every time new content data is available to read.

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 requestFinished () signal is emitted).

The function does not block; instead, it returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by requestStarted () 和 requestFinished ().

When the request is started the requestStarted () signal is emitted. When it is finished the requestFinished () 信号发射。

另请参阅 setHost (), get (), head (), request (), requestStarted (), requestFinished (),和 done ().

int QHttp:: post (const QString & path , const QByteArray & data , QIODevice * to = 0)

这是重载函数。

data is used as the content data of the HTTP request.

[signal] void QHttp:: proxyAuthenticationRequired (const QNetworkProxy & proxy , QAuthenticator * authenticator )

此信号可以被发射当 proxy 要求使用身份验证。 authenticator 然后可以采用所需的详细信息填充对象,以允许身份验证并继续连接。

注意: 使用 QueuedConnection 去连接到此信号是不可能的,因为连接会失败,若身份验证器没有采新信息被填充,当信号返回时。

该函数在 Qt 4.3 引入。

另请参阅 QAuthenticator and QNetworkProxy .

qint64 QHttp:: read ( char * data , qint64 maxlen )

读取 maxlen bytes from the response content into data and returns the number of bytes read. Returns -1 if an error occurred.

另请参阅 get (), post (), request (), readyRead (), bytesAvailable (),和 readAll ().

QByteArray QHttp:: readAll ()

Reads all the bytes from the response content and returns them.

另请参阅 get (), post (), request (), readyRead (), bytesAvailable (),和 read ().

[signal] void QHttp:: readyRead (const QHttpResponseHeader & resp )

This signal is emitted when there is new response data to read.

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.

The response header is passed in resp .

You can read the data with the readAll () 或 read () 函数

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 requestFinished () signal and read the data then instead.

另请参阅 get (), post (), request (), readAll (), read (),和 bytesAvailable ().

int QHttp:: request (const QHttpRequestHeader & header , QIODevice * data = 0, QIODevice * to = 0)

Sends a request to the server set by 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.

The incoming data comes via the data IO device.

If the IO device to is 0 the readyRead () signal is emitted every time new content data is available to read.

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 requestFinished () signal is emitted).

The function does not block; instead, it returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by requestStarted () 和 requestFinished ().

When the request is started the requestStarted () signal is emitted. When it is finished the requestFinished () 信号发射。

另请参阅 setHost (), get (), post (), head (), requestStarted (), requestFinished (),和 done ().

int QHttp:: request (const QHttpRequestHeader & header , const QByteArray & data , QIODevice * to = 0)

这是重载函数。

data is used as the content data of the HTTP request.

[signal] void QHttp:: requestFinished ( int id , bool error )

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 为 false。

另请参阅 requestStarted (), done (), error (),和 errorString ().

[signal] void QHttp:: requestStarted ( int id )

This signal is emitted when processing the request identified by id starts.

另请参阅 requestFinished () 和 done ().

[signal] void QHttp:: responseHeaderReceived (const QHttpResponseHeader & resp )

This signal is emitted when the HTTP header of a server response is available. The header is passed in resp .

另请参阅 get (), post (), head (), request (),和 readyRead ().

int QHttp:: setHost (const QString & hostName , quint16 port = 80)

Sets the HTTP server that is used for requests to hostName 在端口 port .

The function does not block; instead, it returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by requestStarted () 和 requestFinished ().

When the request is started the requestStarted () signal is emitted. When it is finished the requestFinished () 信号发射。

另请参阅 get (), post (), head (), request (), requestStarted (), requestFinished (),和 done ().

int QHttp:: setHost (const QString & hostName , ConnectionMode mode , quint16 port = 0)

Sets the HTTP server that is used for requests to hostName 在端口 port using the connection mode mode .

If port is 0, it will use the default port for the mode used (80 for HTTP and 443 for HTTPS).

The function does not block; instead, it returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by requestStarted () 和 requestFinished ().

When the request is started the requestStarted () signal is emitted. When it is finished the requestFinished () 信号发射。

另请参阅 get (), post (), head (), request (), requestStarted (), requestFinished (),和 done ().

int QHttp:: setProxy (const QString & host , int port , const QString & username = QString(), const QString & password = QString())

Enables HTTP proxy support, using the proxy server host 在端口 port . username and password can be provided if the proxy server requires authentication.

范例:

void Ticker::getTicks()
{
  http = new QHttp(this);
  connect(http, SIGNAL(done(bool)), this, SLOT(showPage()));
  http->setProxy("proxy.example.com", 3128);
  http->setHost("ticker.example.com");
  http->get("/ticks.asp");
}
void Ticker::showPage()
{
  display(http->readAll());
}
					

QHttp supports non-transparent web proxy servers only, such as the Squid Web proxy cache server (from http://www.squid.org/ ). For transparent proxying, such as SOCKS5, use QNetworkProxy 代替。

注意: setProxy() has to be called before setHost () for it to take effect. If setProxy() is called after setHost (), then it will not apply until after setHost () is called again.

另请参阅 QFtp::setProxy ().

int QHttp:: setProxy (const QNetworkProxy & proxy )

这是重载函数。

Enables HTTP proxy support using the proxy settings from proxy 。若 proxy is a transparent proxy, QHttp 将调用 QAbstractSocket::setProxy () on the underlying socket. If the type is QNetworkProxy::HttpCachingProxy , QHttp will behave like the previous function.

注意: for compatibility with Qt 4.3, if the proxy type is QNetworkProxy::HttpProxy and the request type is unencrypted (that is, ConnectionModeHttp ), QHttp will treat the proxy as a caching proxy.

int QHttp:: setSocket ( QTcpSocket * socket )

Replaces the internal QTcpSocket that QHttp uses with socket . This is useful if you want to use your own custom QTcpSocket subclass instead of the plain QTcpSocket that QHttp uses by default. QHttp does not take ownership of the socket, and will not delete socket when destroyed.

The function does not block; instead, it returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by requestStarted () 和 requestFinished ().

When the request is started the requestStarted () signal is emitted. When it is finished the requestFinished () 信号发射。

Note: If QHttp is used in a non-GUI thread that runs its own event loop, you must move socket to that thread before calling setSocket().

另请参阅 QObject::moveToThread () 和 Qt 中的线程支持 .

int QHttp:: setUser (const QString & userName , const QString & password = QString())

This function sets the user name userName and password password for web pages that require authentication.

The function does not block; instead, it returns immediately. The request is scheduled, and its execution is performed asynchronously. The function returns a unique identifier which is passed by requestStarted () 和 requestFinished ().

When the request is started the requestStarted () signal is emitted. When it is finished the requestFinished () 信号发射。

[signal] void QHttp:: sslErrors (const QList < QSslError > & errors )

Forwards the sslErrors signal from the QSslSocket 用于 QHttp . errors is the list of errors that occurred during the SSL handshake. Unless you call ignoreSslErrors () from within a slot connected to this signal when an error occurs, QHttp will tear down the connection immediately after emitting the signal.

该函数在 Qt 4.3 引入。

另请参阅 QSslSocket and QSslSocket::ignoreSslErrors ().

State QHttp:: state () const

Returns the current state of the object. When the state changes, the stateChanged () 信号发射。

另请参阅 State and stateChanged ().

[signal] void QHttp:: stateChanged ( int state )

This signal is emitted when the state of the QHttp object changes. The argument state is the new state of the connection; it is one of the State 值。

This usually happens when a request is started, but it can also happen when the server closes the connection or when a call to close () succeeded.

另请参阅 get (), post (), head (), request (), close (), state (),和 State .