| 63 | |
| 64 | |
| 65 | void UBServerXMLHttpRequest::post(const QUrl& pUrl, const QByteArray& payload) |
| 66 | { |
| 67 | if (mIsRunning) |
| 68 | { |
| 69 | qDebug() << this << "already running ..."; |
| 70 | return; |
| 71 | } |
| 72 | |
| 73 | mIsRunning = true; |
| 74 | |
| 75 | mReplyContent.clear(); |
| 76 | mHasError = false; |
| 77 | |
| 78 | QNetworkRequest request(pUrl); |
| 79 | |
| 80 | request.setHeader(QNetworkRequest::ContentTypeHeader, mContentType); |
| 81 | //request.setRawHeader("ACCEPT", "application/xml"); |
| 82 | request.setHeader(QNetworkRequest::ContentLengthHeader, payload.length()); |
| 83 | |
| 84 | foreach(QString key, mExtraHeaders.keys()) |
| 85 | { |
| 86 | request.setRawHeader(key.toUtf8(), mExtraHeaders.value(key).toUtf8()); |
| 87 | |
| 88 | if (mIsVerbose) |
| 89 | qDebug() << (key + ":" + mExtraHeaders.value(key)); |
| 90 | } |
| 91 | |
| 92 | if (mIsVerbose) |
| 93 | { |
| 94 | qDebug() << "posting" << payload.length() / 1024 << "KB of data to " << pUrl; |
| 95 | qDebug() << "posting" << payload.length() << "B of data to " << pUrl; |
| 96 | qDebug() << "posting -------------------------------------\n"; |
| 97 | qDebug() << QString::fromUtf8(payload); |
| 98 | } |
| 99 | |
| 100 | mPostPayload = payload; |
| 101 | |
| 102 | mReply = mNam->post(request, payload); // UB 4.2 TODO who owns and delete the reply ? |
| 103 | |
| 104 | if (mIsVerbose) |
| 105 | { |
| 106 | qDebug() << "posted --------------------------------------\n"; |
| 107 | } |
| 108 | |
| 109 | connectReply(); |
| 110 | } |
| 111 | |
| 112 | |
| 113 | void UBServerXMLHttpRequest::put(const QUrl& pUrl, const QByteArray& payload) |
no test coverage detected