PDA

View Full Version : Missing "+" when calling QNetworkAccessManager.post()?



MorrisLiang
9th May 2010, 14:25
Here is a strange thing I came cross.When I post something using QNetworkAccessManager:


QByteArray content;
fillContent(content);
qDebug()<<content;
QNetworkAccessManager manager;
manager.post(QNetworkRequest(requestURL),content);

So,I the third line,I can see the output like this:
"signature=LgcuKoofUFtO+LKWPnARcpJyeRo=&signature_method=HMAC-SHA1"

But when the reply finished,I output the data of reply:

qDebug()<<reply->readAll();
I get error message from the sever:
"Signature does not match. Expected: LgcuKoofUFtO+LKWPnARcpJyeRo= Got: LgcuKoofUFtO LKWPnARcpJyeRo="
You see,the "+" in the middle of the signature is missing...
It's pretty strange.Does anybody know how to fix it?

BTW,I can't encode the data to percent-encoding(like %20%4Babcde) before calling QNetworkAccessManager.post(),because the sever will assume this is wrong too.

minimoog
10th May 2010, 10:31
Do some network analyzing with Wireshark. See if signature is correctly sended.

ChrisW67
11th May 2010, 04:15
The "+" character is a stand-in for a space in the POST data encoding scheme (see link below) and is being replaced by a space at the receiving end. Percent encode the literal "+" and all should be well.

17.13.4 Form content types (http://www.w3.org/TR/html401/interact/forms.html#form-content-type)