src/network/access/qnetworkrequest.cpp
changeset 30 5dc02b23752f
parent 18 2f34d5167611
child 33 3e2da88830cd
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
   182      \value HttpPipeliningWasUsedAttribute
   182      \value HttpPipeliningWasUsedAttribute
   183         Replies only, type: QVariant::Bool
   183         Replies only, type: QVariant::Bool
   184         Indicates whether the HTTP pipelining was used for receiving
   184         Indicates whether the HTTP pipelining was used for receiving
   185         this reply.
   185         this reply.
   186 
   186 
       
   187     \value CustomVerbAttribute
       
   188        Requests only, type: QVariant::ByteArray
       
   189         Holds the value for the custom HTTP verb to send (destined for usage
       
   190         of other verbs than GET, POST, PUT and DELETE). This verb is set
       
   191         when calling QNetworkAccessManager::sendCustomRequest().
       
   192 
       
   193     \value CookieLoadControlAttribute
       
   194         Requests only, type: QVariant::Int (default: QNetworkRequest::Automatic)
       
   195         Indicates whether to send 'Cookie' headers in the request.
       
   196 
       
   197         This attribute is set to false by QtWebKit when creating a cross-origin
       
   198         XMLHttpRequest where withCredentials has not been set explicitly to true by the
       
   199         Javascript that created the request.
       
   200 
       
   201         See http://www.w3.org/TR/XMLHttpRequest2/#credentials-flag for more information.
       
   202 
       
   203         \since 4.7
       
   204 
       
   205      \value CookieSaveControlAttribute
       
   206         Requests only, type: QVariant::Int (default: QNetworkRequest::Automatic)
       
   207         Indicates whether to save 'Cookie' headers received from the server in reply
       
   208         to the request.
       
   209 
       
   210         This attribute is set to false by QtWebKit when creating a cross-origin
       
   211         XMLHttpRequest where withCredentials has not been set explicitly to true by the
       
   212         Javascript that created the request.
       
   213 
       
   214         See http://www.w3.org/TR/XMLHttpRequest2/#credentials-flag for more information.
       
   215 
       
   216         \since 4.7
       
   217 
       
   218      \value AuthenticationReuseControlAttribute
       
   219         Requests only, type: QVariant::Int (default: QNetworkRequest::Automatic)
       
   220         Indicates whether to use cached authorization credentials in the request,
       
   221         if available. If this is set to QNetworkRequest::Manual and the authentication
       
   222         mechanism is 'Basic' or 'Digest', Qt will not send an an 'Authorization' HTTP
       
   223         header with any cached credentials it may have for the request's URL.
       
   224 
       
   225         This attribute is set to QNetworkRequest::Manual by QtWebKit when creating a cross-origin
       
   226         XMLHttpRequest where withCredentials has not been set explicitly to true by the
       
   227         Javascript that created the request.
       
   228 
       
   229         See http://www.w3.org/TR/XMLHttpRequest2/#credentials-flag for more information.
       
   230 
       
   231         \since 4.7
       
   232 
   187     \value User
   233     \value User
   188         Special type. Additional information can be passed in
   234         Special type. Additional information can be passed in
   189         QVariants with types ranging from User to UserMax. The default
   235         QVariants with types ranging from User to UserMax. The default
   190         implementation of Network Access will ignore any request
   236         implementation of Network Access will ignore any request
   191         attributes in this range and it will not produce any
   237         attributes in this range and it will not produce any
   214 
   260 
   215     \value AlwaysCache          only load from cache, indicating error
   261     \value AlwaysCache          only load from cache, indicating error
   216     if the item was not cached (i.e., off-line mode)
   262     if the item was not cached (i.e., off-line mode)
   217 */
   263 */
   218 
   264 
       
   265 /*!
       
   266     \enum QNetworkRequest::LoadControl
       
   267     \since 4.7
       
   268 
       
   269     Indicates if an aspect of the request's loading mechanism has been
       
   270     manually overridden, e.g. by QtWebKit.
       
   271 
       
   272     \value Automatic            default value: indicates default behaviour.
       
   273 
       
   274     \value Manual               indicates behaviour has been manually overridden.
       
   275 */
       
   276 
   219 class QNetworkRequestPrivate: public QSharedData, public QNetworkHeadersPrivate
   277 class QNetworkRequestPrivate: public QSharedData, public QNetworkHeadersPrivate
   220 {
   278 {
   221 public:
   279 public:
   222     inline QNetworkRequestPrivate()
   280     inline QNetworkRequestPrivate()
       
   281         : priority(QNetworkRequest::NormalPriority)
   223 #ifndef QT_NO_OPENSSL
   282 #ifndef QT_NO_OPENSSL
   224         : sslConfiguration(0)
   283         , sslConfiguration(0)
   225 #endif
   284 #endif
   226     { qRegisterMetaType<QNetworkRequest>(); }
   285     { qRegisterMetaType<QNetworkRequest>(); }
   227     ~QNetworkRequestPrivate()
   286     ~QNetworkRequestPrivate()
   228     {
   287     {
   229 #ifndef QT_NO_OPENSSL
   288 #ifndef QT_NO_OPENSSL
   234 
   293 
   235     QNetworkRequestPrivate(const QNetworkRequestPrivate &other)
   294     QNetworkRequestPrivate(const QNetworkRequestPrivate &other)
   236         : QSharedData(other), QNetworkHeadersPrivate(other)
   295         : QSharedData(other), QNetworkHeadersPrivate(other)
   237     {
   296     {
   238         url = other.url;
   297         url = other.url;
       
   298         priority = other.priority;
   239 
   299 
   240 #ifndef QT_NO_OPENSSL
   300 #ifndef QT_NO_OPENSSL
   241         sslConfiguration = 0;
   301         sslConfiguration = 0;
   242         if (other.sslConfiguration)
   302         if (other.sslConfiguration)
   243             sslConfiguration = new QSslConfiguration(*other.sslConfiguration);
   303             sslConfiguration = new QSslConfiguration(*other.sslConfiguration);
   245     }
   305     }
   246 
   306 
   247     inline bool operator==(const QNetworkRequestPrivate &other) const
   307     inline bool operator==(const QNetworkRequestPrivate &other) const
   248     {
   308     {
   249         return url == other.url &&
   309         return url == other.url &&
       
   310             priority == other.priority &&
   250             rawHeaders == other.rawHeaders &&
   311             rawHeaders == other.rawHeaders &&
   251             attributes == other.attributes;
   312             attributes == other.attributes;
   252         // don't compare cookedHeaders
   313         // don't compare cookedHeaders
   253     }
   314     }
   254 
   315 
   255     QUrl url;
   316     QUrl url;
       
   317     QNetworkRequest::Priority priority;
   256 #ifndef QT_NO_OPENSSL
   318 #ifndef QT_NO_OPENSSL
   257     mutable QSslConfiguration *sslConfiguration;
   319     mutable QSslConfiguration *sslConfiguration;
   258 #endif
   320 #endif
   259 };
   321 };
   260 
   322 
   514     \sa setOriginatingObject()
   576     \sa setOriginatingObject()
   515 */
   577 */
   516 QObject *QNetworkRequest::originatingObject() const
   578 QObject *QNetworkRequest::originatingObject() const
   517 {
   579 {
   518     return d->originatingObject.data();
   580     return d->originatingObject.data();
       
   581 }
       
   582 
       
   583 /*!
       
   584     \since 4.7
       
   585 
       
   586     Return the priority of this request.
       
   587 
       
   588     \sa setPriority()
       
   589 */
       
   590 QNetworkRequest::Priority QNetworkRequest::priority() const
       
   591 {
       
   592     return d->priority;
       
   593 }
       
   594 
       
   595 /*! \enum QNetworkRequest::Priority
       
   596 
       
   597   \since 4.7
       
   598   
       
   599   This enum lists the possible network request priorities.
       
   600 
       
   601   \value HighPriority   High priority
       
   602   \value NormalPriority Normal priority
       
   603   \value LowPriority    Low priority
       
   604  */
       
   605 
       
   606 /*!
       
   607     \since 4.7
       
   608 
       
   609     Set the priority of this request to \a priority.
       
   610 
       
   611     \note The \a priority is only a hint to the network access
       
   612     manager.  It can use it or not. Currently it is used for HTTP to
       
   613     decide which request should be sent first to a server.
       
   614 
       
   615     \sa priority()
       
   616 */
       
   617 void QNetworkRequest::setPriority(Priority priority)
       
   618 {
       
   619     d->priority = priority;
   519 }
   620 }
   520 
   621 
   521 static QByteArray headerName(QNetworkRequest::KnownHeaders header)
   622 static QByteArray headerName(QNetworkRequest::KnownHeaders header)
   522 {
   623 {
   523     switch (header) {
   624     switch (header) {