| Line | Source | Count |
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | | - |
| 9 | | - |
| 10 | | - |
| 11 | | - |
| 12 | | - |
| 13 | | - |
| 14 | | - |
| 15 | | - |
| 16 | | - |
| 17 | | - |
| 18 | | - |
| 19 | | - |
| 20 | | - |
| 21 | | - |
| 22 | | - |
| 23 | | - |
| 24 | | - |
| 25 | | - |
| 26 | | - |
| 27 | | - |
| 28 | | - |
| 29 | | - |
| 30 | | - |
| 31 | | - |
| 32 | | - |
| 33 | | - |
| 34 | | - |
| 35 | | - |
| 36 | | - |
| 37 | | - |
| 38 | | - |
| 39 | | - |
| 40 | #include "qhttpnetworkrequest_p.h" | - |
| 41 | #include "private/qnoncontiguousbytedevice_p.h" | - |
| 42 | | - |
| 43 | #ifndef QT_NO_HTTP | - |
| 44 | | - |
| 45 | QT_BEGIN_NAMESPACE | - |
| 46 | | - |
| 47 | QHttpNetworkRequestPrivate::QHttpNetworkRequestPrivate(QHttpNetworkRequest::Operation op, | - |
| 48 | QHttpNetworkRequest::Priority pri, const QUrl &newUrl) | - |
| 49 | : QHttpNetworkHeaderPrivate(newUrl), operation(op), priority(pri), uploadByteDevice(0), | - |
| 50 | autoDecompress(false), pipeliningAllowed(false), spdyAllowed(false), | - |
| 51 | withCredentials(true), preConnect(false), followRedirect(false), redirectCount(0) | - |
| 52 | { | - |
| 53 | } | - |
| 54 | | - |
| 55 | QHttpNetworkRequestPrivate::QHttpNetworkRequestPrivate(const QHttpNetworkRequestPrivate &other) | - |
| 56 | : QHttpNetworkHeaderPrivate(other) | - |
| {), | |
| 57 | operation=(other.operation;), | - |
| 58 | customVerb(other.customVerb), | - |
| 59 | priority=(other.priority;), | - |
| 60 | uploadByteDevice=(other.uploadByteDevice;), | - |
| 61 | autoDecompress=(other.autoDecompress;), | - |
| 62 | pipeliningAllowed=(other.pipeliningAllowed;), | - |
| 63 | spdyAllowed=(other.spdyAllowed; | - |
| customVerb = other.customVerb;), | |
| 64 | withCredentials=(other.withCredentials;), | - |
| 65 | ssl=(other.ssl;), | - |
| 66 | preConnect=(other.preConnect;), | - |
| 67 | followRedirect=(other.followRedirect;), | - |
| 68 | redirectCount=(other.redirectCount;) | - |
| 69 | { | - |
| 70 | }executed 2184 times by 8 tests: end of blockExecuted by:- tst_QAbstractNetworkCache
- tst_QHttpNetworkConnection
- tst_QNetworkAccessManager_And_QProgressDialog
- tst_QNetworkDiskCache
- tst_QNetworkProxyFactory
- tst_QNetworkReply
- tst_QXmlInputSource
- tst_Spdy
| 2184 |
| 71 | | - |
| 72 | QHttpNetworkRequestPrivate::~QHttpNetworkRequestPrivate() | - |
| 73 | { | - |
| 74 | } | - |
| 75 | | - |
| 76 | bool QHttpNetworkRequestPrivate::operator==(const QHttpNetworkRequestPrivate &other) const | - |
| 77 | { | - |
| 78 | return QHttpNetworkHeaderPrivate::operator==(other) | - |
| 79 | && (operation == other.operation) | - |
| 80 | && (priority == other.priority) | - |
| 81 | && (uploadByteDevice == other.uploadByteDevice) | - |
| 82 | && (autoDecompress == other.autoDecompress) | - |
| 83 | && (pipeliningAllowed == other.pipeliningAllowed) | - |
| 84 | && (spdyAllowed == other.spdyAllowed) | - |
| 85 | | - |
| 86 | && (operation != QHttpNetworkRequest::Custom || (customVerb == other.customVerb)) | - |
| 87 | && (withCredentials == other.withCredentials) | - |
| 88 | && (ssl == other.ssl) | - |
| 89 | && (preConnect == other.preConnect); | - |
| 90 | } | - |
| 91 | | - |
| 92 | QByteArray QHttpNetworkRequest::methodName() const | - |
| 93 | { | - |
| 94 | switch (d->operation) { | - |
| 95 | case QHttpNetworkRequest::Get: | - |
| 96 | return "GET"; | - |
| 97 | case QHttpNetworkRequest::Head: | - |
| 98 | return "HEAD"; | - |
| 99 | case QHttpNetworkRequest::Post: | - |
| 100 | return "POST"; | - |
| 101 | case QHttpNetworkRequest::Options: | - |
| 102 | return "OPTIONS"; | - |
| 103 | case QHttpNetworkRequest::Put: | - |
| 104 | return "PUT"; | - |
| 105 | case QHttpNetworkRequest::Delete: | - |
| 106 | return "DELETE"; | - |
| 107 | case QHttpNetworkRequest::Trace: | - |
| 108 | return "TRACE"; | - |
| 109 | case QHttpNetworkRequest::Connect: | - |
| 110 | return "CONNECT"; | - |
| 111 | case QHttpNetworkRequest::Custom: | - |
| 112 | return d->customVerb; | - |
| 113 | default: | - |
| 114 | break; | - |
| 115 | } | - |
| 116 | return QByteArray(); | - |
| 117 | } | - |
| 118 | | - |
| 119 | QByteArray QHttpNetworkRequest::uri(bool throughProxy) const | - |
| 120 | { | - |
| 121 | QUrl::FormattingOptions format(QUrl::RemoveFragment | QUrl::RemoveUserInfo | QUrl::FullyEncoded); | - |
| 122 | | - |
| 123 | | - |
| 124 | if (d->operation == QHttpNetworkRequest::Post && !d->uploadByteDevice) | - |
| 125 | format |= QUrl::RemoveQuery; | - |
| 126 | | - |
| 127 | if (!throughProxy) | - |
| 128 | format |= QUrl::RemoveScheme | QUrl::RemoveAuthority; | - |
| 129 | QUrl copy = d->url; | - |
| 130 | if (copy.path().isEmpty()) | - |
| 131 | copy.setPath(QStringLiteral("/")); | - |
| 132 | QByteArray uri = copy.toEncoded(format); | - |
| 133 | return uri; | - |
| 134 | } | - |
| 135 | | - |
| 136 | QByteArray QHttpNetworkRequestPrivate::header(const QHttpNetworkRequest &request, bool throughProxy) | - |
| 137 | { | - |
| 138 | QList<QPair<QByteArray, QByteArray> > fields = request.header(); | - |
| 139 | QByteArray ba; | - |
| 140 | ba.reserve(40 + fields.length()*25); | - |
| 141 | | - |
| 142 | ba += request.methodName(); | - |
| 143 | ba += ' '; | - |
| 144 | ba += request.uri(throughProxy); | - |
| 145 | | - |
| 146 | ba += " HTTP/"; | - |
| 147 | ba += QByteArray::number(request.majorVersion()); | - |
| 148 | ba += '.'; | - |
| 149 | ba += QByteArray::number(request.minorVersion()); | - |
| 150 | ba += "\r\n"; | - |
| 151 | | - |
| 152 | QList<QPair<QByteArray, QByteArray> >::const_iterator it = fields.constBegin(); | - |
| 153 | QList<QPair<QByteArray, QByteArray> >::const_iterator endIt = fields.constEnd(); | - |
| 154 | for (; it != endIt; ++it) { | - |
| 155 | ba += it->first; | - |
| 156 | ba += ": "; | - |
| 157 | ba += it->second; | - |
| 158 | ba += "\r\n"; | - |
| 159 | } | - |
| 160 | if (request.d->operation == QHttpNetworkRequest::Post) { | - |
| 161 | | - |
| 162 | if (request.headerField("content-type").isEmpty() && ((request.d->uploadByteDevice && request.d->uploadByteDevice->size() > 0) || request.d->url.hasQuery())) { | - |
| 163 | | - |
| 164 | | - |
| 165 | | - |
| 166 | qWarning("content-type missing in HTTP POST, defaulting to application/x-www-form-urlencoded. Use QNetworkRequest::setHeader() to fix this problem."); | - |
| 167 | ba += "Content-Type: application/x-www-form-urlencoded\r\n"; | - |
| 168 | } | - |
| 169 | if (!request.d->uploadByteDevice && request.d->url.hasQuery()) { | - |
| 170 | QByteArray query = request.d->url.query(QUrl::FullyEncoded).toLatin1(); | - |
| 171 | ba += "Content-Length: "; | - |
| 172 | ba += QByteArray::number(query.size()); | - |
| 173 | ba += "\r\n\r\n"; | - |
| 174 | ba += query; | - |
| 175 | } else { | - |
| 176 | ba += "\r\n"; | - |
| 177 | } | - |
| 178 | } else { | - |
| 179 | ba += "\r\n"; | - |
| 180 | } | - |
| 181 | return ba; | - |
| 182 | } | - |
| 183 | | - |
| 184 | | - |
| 185 | | - |
| 186 | | - |
| 187 | QHttpNetworkRequest::QHttpNetworkRequest(const QUrl &url, Operation operation, Priority priority) | - |
| 188 | : d(new QHttpNetworkRequestPrivate(operation, priority, url)) | - |
| 189 | { | - |
| 190 | } | - |
| 191 | | - |
| 192 | QHttpNetworkRequest::QHttpNetworkRequest(const QHttpNetworkRequest &other) | - |
| 193 | : QHttpNetworkHeader(other), d(other.d) | - |
| 194 | { | - |
| 195 | } | - |
| 196 | | - |
| 197 | QHttpNetworkRequest::~QHttpNetworkRequest() | - |
| 198 | { | - |
| 199 | } | - |
| 200 | | - |
| 201 | QUrl QHttpNetworkRequest::url() const | - |
| 202 | { | - |
| 203 | return d->url; | - |
| 204 | } | - |
| 205 | void QHttpNetworkRequest::setUrl(const QUrl &url) | - |
| 206 | { | - |
| 207 | d->url = url; | - |
| 208 | } | - |
| 209 | | - |
| 210 | bool QHttpNetworkRequest::isSsl() const | - |
| 211 | { | - |
| 212 | return d->ssl; | - |
| 213 | } | - |
| 214 | void QHttpNetworkRequest::setSsl(bool s) | - |
| 215 | { | - |
| 216 | d->ssl = s; | - |
| 217 | } | - |
| 218 | | - |
| 219 | bool QHttpNetworkRequest::isPreConnect() const | - |
| 220 | { | - |
| 221 | return d->preConnect; | - |
| 222 | } | - |
| 223 | void QHttpNetworkRequest::setPreConnect(bool preConnect) | - |
| 224 | { | - |
| 225 | d->preConnect = preConnect; | - |
| 226 | } | - |
| 227 | | - |
| 228 | bool QHttpNetworkRequest::isFollowRedirects() const | - |
| 229 | { | - |
| 230 | return d->followRedirect; | - |
| 231 | } | - |
| 232 | | - |
| 233 | void QHttpNetworkRequest::setFollowRedirects(bool followRedirect) | - |
| 234 | { | - |
| 235 | d->followRedirect = followRedirect; | - |
| 236 | } | - |
| 237 | | - |
| 238 | int QHttpNetworkRequest::redirectCount() const | - |
| 239 | { | - |
| 240 | return d->redirectCount; | - |
| 241 | } | - |
| 242 | | - |
| 243 | void QHttpNetworkRequest::setRedirectCount(int count) | - |
| 244 | { | - |
| 245 | d->redirectCount = count; | - |
| 246 | } | - |
| 247 | | - |
| 248 | qint64 QHttpNetworkRequest::contentLength() const | - |
| 249 | { | - |
| 250 | return d->contentLength(); | - |
| 251 | } | - |
| 252 | | - |
| 253 | void QHttpNetworkRequest::setContentLength(qint64 length) | - |
| 254 | { | - |
| 255 | d->setContentLength(length); | - |
| 256 | } | - |
| 257 | | - |
| 258 | QList<QPair<QByteArray, QByteArray> > QHttpNetworkRequest::header() const | - |
| 259 | { | - |
| 260 | return d->fields; | - |
| 261 | } | - |
| 262 | | - |
| 263 | QByteArray QHttpNetworkRequest::headerField(const QByteArray &name, const QByteArray &defaultValue) const | - |
| 264 | { | - |
| 265 | return d->headerField(name, defaultValue); | - |
| 266 | } | - |
| 267 | | - |
| 268 | void QHttpNetworkRequest::setHeaderField(const QByteArray &name, const QByteArray &data) | - |
| 269 | { | - |
| 270 | d->setHeaderField(name, data); | - |
| 271 | } | - |
| 272 | | - |
| 273 | QHttpNetworkRequest &QHttpNetworkRequest::operator=(const QHttpNetworkRequest &other) | - |
| 274 | { | - |
| 275 | d = other.d; | - |
| 276 | return *this; | - |
| 277 | } | - |
| 278 | | - |
| 279 | bool QHttpNetworkRequest::operator==(const QHttpNetworkRequest &other) const | - |
| 280 | { | - |
| 281 | return d->operator==(*other.d); | - |
| 282 | } | - |
| 283 | | - |
| 284 | QHttpNetworkRequest::Operation QHttpNetworkRequest::operation() const | - |
| 285 | { | - |
| 286 | return d->operation; | - |
| 287 | } | - |
| 288 | | - |
| 289 | void QHttpNetworkRequest::setOperation(Operation operation) | - |
| 290 | { | - |
| 291 | d->operation = operation; | - |
| 292 | } | - |
| 293 | | - |
| 294 | QByteArray QHttpNetworkRequest::customVerb() const | - |
| 295 | { | - |
| 296 | return d->customVerb; | - |
| 297 | } | - |
| 298 | | - |
| 299 | void QHttpNetworkRequest::setCustomVerb(const QByteArray &customVerb) | - |
| 300 | { | - |
| 301 | d->customVerb = customVerb; | - |
| 302 | } | - |
| 303 | | - |
| 304 | QHttpNetworkRequest::Priority QHttpNetworkRequest::priority() const | - |
| 305 | { | - |
| 306 | return d->priority; | - |
| 307 | } | - |
| 308 | | - |
| 309 | void QHttpNetworkRequest::setPriority(Priority priority) | - |
| 310 | { | - |
| 311 | d->priority = priority; | - |
| 312 | } | - |
| 313 | | - |
| 314 | bool QHttpNetworkRequest::isPipeliningAllowed() const | - |
| 315 | { | - |
| 316 | return d->pipeliningAllowed; | - |
| 317 | } | - |
| 318 | | - |
| 319 | void QHttpNetworkRequest::setPipeliningAllowed(bool b) | - |
| 320 | { | - |
| 321 | d->pipeliningAllowed = b; | - |
| 322 | } | - |
| 323 | | - |
| 324 | bool QHttpNetworkRequest::isSPDYAllowed() const | - |
| 325 | { | - |
| 326 | return d->spdyAllowed; | - |
| 327 | } | - |
| 328 | | - |
| 329 | void QHttpNetworkRequest::setSPDYAllowed(bool b) | - |
| 330 | { | - |
| 331 | d->spdyAllowed = b; | - |
| 332 | } | - |
| 333 | | - |
| 334 | bool QHttpNetworkRequest::withCredentials() const | - |
| 335 | { | - |
| 336 | return d->withCredentials; | - |
| 337 | } | - |
| 338 | | - |
| 339 | void QHttpNetworkRequest::setWithCredentials(bool b) | - |
| 340 | { | - |
| 341 | d->withCredentials = b; | - |
| 342 | } | - |
| 343 | | - |
| 344 | void QHttpNetworkRequest::setUploadByteDevice(QNonContiguousByteDevice *bd) | - |
| 345 | { | - |
| 346 | d->uploadByteDevice = bd; | - |
| 347 | } | - |
| 348 | | - |
| 349 | QNonContiguousByteDevice* QHttpNetworkRequest::uploadByteDevice() const | - |
| 350 | { | - |
| 351 | return d->uploadByteDevice; | - |
| 352 | } | - |
| 353 | | - |
| 354 | int QHttpNetworkRequest::majorVersion() const | - |
| 355 | { | - |
| 356 | return 1; | - |
| 357 | } | - |
| 358 | | - |
| 359 | int QHttpNetworkRequest::minorVersion() const | - |
| 360 | { | - |
| 361 | return 1; | - |
| 362 | } | - |
| 363 | | - |
| 364 | | - |
| 365 | QT_END_NAMESPACE | - |
| 366 | | - |
| 367 | #endif | - |
| 368 | | - |
| | |