|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.core.QIODevice
com.trolltech.qt.network.QNetworkReply
public abstract class QNetworkReply
The QNetworkReply class contains the data and headers for a request posted with QNetworkAccessManager
The QNetworkReply class contains the data and meta data related to a request posted with QNetworkAccessManager
. Like QNetworkRequest
, it contains a URL and headers (both in parsed and raw form), some information about the reply's state and the contents of the reply itself.
QNetworkReply is a sequential-access QIODevice
, which means that once data is read from the object, it no longer kept by the device. It is therefore the application's responsibility to keep this data if it needs to. Whenever more data is received from the network and processed, the readyRead()
signal is emitted.
The downloadProgress()
signal is also emitted when data is received, but the number of bytes contained in it may not represent the actual bytes received, if any transformation is done to the contents (for example, decompressing and removing the protocol overhead).
Even though QNetworkReply is a QIODevice
connected to the contents of the reply, it also emits the uploadProgress()
signal, which indicates the progress of the upload for operations that have such content.
QNetworkRequest
, and QNetworkAccessManager
.
Nested Class Summary | |
---|---|
static class |
QNetworkReply.NetworkError
Indicates all possible error conditions found during the processing of the request. |
Nested classes/interfaces inherited from class com.trolltech.qt.core.QIODevice |
---|
QIODevice.OpenMode, QIODevice.OpenModeFlag |
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9 |
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal |
Field Summary | |
---|---|
QSignalEmitter.Signal2 |
downloadProgress
This signal takes 2 generic argument(s). |
QSignalEmitter.Signal1 |
error
This signal takes 1 generic argument(s). |
QSignalEmitter.Signal0 |
finished
This signal is emitted when the reply has finished processing. |
QSignalEmitter.Signal0 |
metaDataChanged
FIXME. |
QSignalEmitter.Signal2 |
uploadProgress
This signal takes 2 generic argument(s). |
Fields inherited from class com.trolltech.qt.core.QIODevice |
---|
aboutToClose, bytesWritten, readChannelFinished, readyRead |
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
currentSender |
Constructor Summary | |
---|---|
protected |
QNetworkReply()
Creates a QNetworkReply object with parent parent. |
protected |
QNetworkReply(QObject parent)
Creates a QNetworkReply object with parent parent. |
Method Summary | |
---|---|
abstract void |
abort()
Aborts the operation immediately and close down any network connections still open. |
java.lang.Object |
attribute(QNetworkRequest.Attribute code)
Returns the attribute associated with the code code. |
QNetworkReply.NetworkError |
error()
Returns the error that was found during the processing of this request. |
boolean |
hasRawHeader(QByteArray headerName)
Returns true if the raw header of name headerName was sent by the remote server |
java.lang.Object |
header(QNetworkRequest.KnownHeaders header)
Returns the value of the known header header, if that header was sent by the remote server. |
void |
ignoreSslErrors()
If this function is called, SSL errors related to network connection will be ignored, including certificate validation errors. |
QNetworkAccessManager |
manager()
Returns the QNetworkAccessManager that was used to create this QNetworkReply object. |
QNetworkAccessManager.Operation |
operation()
Returns the operation that was posted for this reply. |
QByteArray |
rawHeader(QByteArray headerName)
Returns the raw contents of the header headerName as sent by the remote server. |
java.util.List |
rawHeaderList()
Returns a list of headers fields that were sent by the remote server, in the order that they were sent. |
long |
readBufferSize()
Returns the size of the read buffer, in bytes. |
QNetworkRequest |
request()
Returns the request that was posted for this reply. |
protected void |
setAttribute(QNetworkRequest.Attribute code,
java.lang.Object value)
Sets the attribute code to have value value. |
protected void |
setError(QNetworkReply.NetworkError errorCode,
java.lang.String errorString)
Sets the error condition to be errorCode. |
protected void |
setHeader(QNetworkRequest.KnownHeaders header,
java.lang.Object value)
Sets the known header header to be of value value. |
protected void |
setOperation(QNetworkAccessManager.Operation operation)
Sets the associated operation for this object to be operation. |
protected void |
setRawHeader(QByteArray headerName,
QByteArray value)
Sets the raw header headerName to be of value value. |
void |
setReadBufferSize(long size)
Sets the size of the read buffer to be size bytes. |
protected void |
setRequest(QNetworkRequest request)
Sets the associated request for this object to be request. |
protected void |
setUrl(QUrl url)
Sets the URL being processed to be url. |
QUrl |
url()
Returns the URL of the content downloaded or uploaded. |
Methods inherited from class com.trolltech.qt.core.QIODevice |
---|
atEnd, bytesAvailable, bytesToWrite, canReadLine, close, errorString, getByte, isOpen, isReadable, isSequential, isTextModeEnabled, isWritable, open, open, openMode, peek, peek, pos, putByte, read, read, readAll, readData, readLine, readLine, readLine, readLineData, reset, seek, setErrorString, setOpenMode, setOpenMode, setTextModeEnabled, size, ungetByte, waitForBytesWritten, waitForReadyRead, write, write, writeData |
Methods inherited from class com.trolltech.qt.core.QObject |
---|
childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
__qt_signalInitialization |
Methods inherited from class java.lang.Object |
---|
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Field Detail |
---|
public final QSignalEmitter.Signal2 downloadProgress
This signal takes 2 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Long(named: bytesReceived), java.lang.Long(named: bytesTotal)>:
This signal is emitted to indicate the progress of the download part of this network request, if there's any. If there's no download associated with this request, this signal will be emitted once with 0 as the value of both bytesReceived and bytesTotal.
The bytesReceived parameter indicates the number of bytes received, while bytesTotal indicates the total number of bytes expected to be downloaded. If the number of bytes to be downloaded is not known, bytesTotal will be -1.
The download is finished when bytesReceived is equal to bytesTotal. At that time, bytesTotal will not be -1.
This signal is suitable to connecting to QProgressBar::setValue()
to update the QProgressBar
that provides user feedback.
Note that the values of both bytesReceived and bytesTotal may be different from size()
, the total number of bytes obtained through read()
or readAll()
, or the value of the header(ContentLengthHeader). The reason for that is that there may be protocol overhead or the data may be compressed during the download.
uploadProgress()
, and bytesAvailable()
.
public final QSignalEmitter.Signal1 error
This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.network.QNetworkReply$NetworkError(named: code)>:
This signal is emitted when the reply detects an error in processing. The finished()
signal will probably follow, indicating that the connection is over.
The code parameter contains the code of the error that was detected. Call errorString()
to obtain a textual representation of the error condition.
error()
, and errorString()
.
public final QSignalEmitter.Signal0 finished
Unless close() has been called, the reply will be still be opened for reading, so the data can be retrieved by calls to read()
or readAll()
. In particular, if no calls to read()
were made as a result of readyRead()
, a call to readAll()
will retrieve the full contents in a QByteArray
.
This signal is emitted in tandem with QNetworkAccessManager::finished()
where that signal's reply parameter is this object.
QNetworkAccessManager::finished()
.
public final QSignalEmitter.Signal0 metaDataChanged
This signal is emitted whenever the metadata in this reply changes. metadata is any information that is not the content (data) itself, including the network headers. In the majority of cases, the metadata will be known fully by the time the first byte of data is received. However, it is possible to receive updates of headers or other metadata during the processing of the data.
header()
, rawHeaderList()
, rawHeader()
, and hasRawHeader()
.
public final QSignalEmitter.Signal2 uploadProgress
This signal takes 2 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Long(named: bytesSent), java.lang.Long(named: bytesTotal)>:
This signal is emitted to indicate the progress of the upload part of this network request, if there's any. If there's no upload associated with this request, this signal will not be emitted.
The bytesSent parameter indicates the number of bytes uploaded, while bytesTotal indicates the total number of bytes to be uploaded. If the number of bytes to be uploaded could not be determined, bytesTotal will be -1.
The upload is finished when bytesSent is equal to bytesTotal. At that time, bytesTotal will not be -1.
This signal is suitable to connecting to QProgressBar::setValue()
to update the QProgressBar
that provides user feedback.
downloadProgress()
.
Constructor Detail |
---|
protected QNetworkReply()
You cannot directly instantiate QNetworkReply objects. Use QNetworkAccessManager
functions to do that.
protected QNetworkReply(QObject parent)
You cannot directly instantiate QNetworkReply objects. Use QNetworkAccessManager
functions to do that.
Method Detail |
---|
public final java.lang.Object attribute(QNetworkRequest.Attribute code)
QVariant
(type QVariant::Null). You can expect the default values listed in QNetworkRequest::Attribute
to be applied to the values returned by this function.
setAttribute()
, and QNetworkRequest::Attribute
.
public final QNetworkReply.NetworkError error()
NoError
. setError()
.
public final boolean hasRawHeader(QByteArray headerName)
rawHeader()
.
public final java.lang.Object header(QNetworkRequest.KnownHeaders header)
QVariant
. rawHeader()
, setHeader()
, and QNetworkRequest::header()
.
public final QNetworkAccessManager manager()
QNetworkAccessManager
that was used to create this QNetworkReply object. Initially, it is also the parent object.
public final QNetworkAccessManager.Operation operation()
setOperation()
.
public final QByteArray rawHeader(QByteArray headerName)
hasRawHeader()
to verify if the server sent such header field. setRawHeader()
, hasRawHeader()
, and header()
.
public final java.util.List rawHeaderList()
public final long readBufferSize()
setReadBufferSize()
.
public final QNetworkRequest request()
QNetworkRequest::url()
, url()
, and setRequest()
.
protected final void setAttribute(QNetworkRequest.Attribute code, java.lang.Object value)
QVariant
, the attribute will be unset. attribute()
, and QNetworkRequest::setAttribute()
.
protected final void setError(QNetworkReply.NetworkError errorCode, java.lang.String errorString)
Calling setError()
does not emit the error(QNetworkReply::NetworkError
) signal.
error()
, and errorString()
.
protected final void setHeader(QNetworkRequest.KnownHeaders header, java.lang.Object value)
header()
, setRawHeader()
, and QNetworkRequest::setHeader()
.
protected final void setOperation(QNetworkAccessManager.Operation operation)
operation()
. Note: the operation should be set when this object is created and not changed again.
operation()
, and setRequest()
.
protected final void setRawHeader(QByteArray headerName, QByteArray value)
If headerName matches a known header, the value value will be parsed and the corresponding parsed form will also be set.
rawHeader()
, header()
, setHeader()
, and QNetworkRequest::setRawHeader()
.
protected final void setRequest(QNetworkRequest request)
request()
. Note: the request should be set when this object is created and not changed again.
request()
, and setOperation()
.
protected final void setUrl(QUrl url)
url()
, request()
, and QNetworkRequest::url()
.
public final QUrl url()
request()
, setUrl()
, and QNetworkRequest::url()
.
public abstract void abort()
public void ignoreSslErrors()
Note that calling this function without restraint may pose a security risk for your application. Use it with care.
This function can be called from the slot connected to the sslErrors() signal, which indicates which errors were found.
public void setReadBufferSize(long size)
QIODevice::read()
. Setting the buffer size to 0 will make the buffer unlimited in size. QNetworkReply will try to stop reading from the network once this buffer is full (i.e., bytesAvailable()
returns size or more), thus causing the download to throttle down as well. If the buffer is not limited in size, QNetworkReply will try to download as fast as possible from the network.
Unlike QAbstractSocket::setReadBufferSize()
, QNetworkReply cannot guarantee precision in the read buffer size. That is, bytesAvailable()
can return more than size.
readBufferSize()
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |