PDA

View Full Version : QHttp Header formation -reg



tietotesthyd
30th April 2009, 05:50
Hi,

We are trying to build QHttp header to get google authentication, but we are ran into troubles while doing that. Can anybody suggest us where we were doing wrong? Please look at following code. Initially we tried with curl command line utility and we were able to get response from google. Just have look at below code..

curl command (successfully got reply from google):
/*
Curl Command:
curl https://google.com/accounts/ClientLogin HTTP/1.0
-d Content-type=application/x-www-form-urlencoded
-d Content-Length=121
-d accountType=HOSTED_OR_GOOGLE
-d Email="xxx@gmail.com"
-d Passwd="xxx"
-d service=lh2
-d source="Blogger-1.0"
-d UserAgent="Client"
*/

code written in Qt:
setHost("google.com",443);

QHttpRequestHeader header("GET","/accounts/ClientLogin");
header.setValue("Host","https://google.com");
header.setValue("Port","443");
header.setContentType("application/x-www-form-urlencoded");
header.setValue("Content-Length", "121");
header.setValue("accountType","HOSTED_OR_GOOGLE");
header.setValue("Email","...@gmail.com");
header.setValue("Passwd","...");
header.setValue("service","lh2");
header.setValue("source","Blogger-1.0");
header.setValue("UserAgent","Client");

int i = request(header,arr);
qDebug()<<"request value = "<<i<<arr;

connect(this,
SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)),
this,
SLOT(displayData(const QHttpResponseHeader &)));
connect(this,
SIGNAL(stateChanged(int)),
this,
SLOT(displayStateValue(int)));
connect(this,
SIGNAL(requestFinished(int, bool)),
this,
SLOT(displayError(int, bool)));

checking arr buffer after requestFinished signal was emitted!

Thanks in advance.

Regards,
Developer

Lykurg
30th April 2009, 07:49
Go on, REMOVE THE PASSWORD!!!

e8johan
30th April 2009, 08:04
I'm not sure if you're doing this right... have you inherited QHttp? I'd suggest using a QHttp instance from your class, then using the QHttpResponseHeader that you get from the responseHeaderReceived signal, i.e. not looking at the contents of arr.

e8johan
30th April 2009, 08:05
Go on, REMOVE THE PASSWORD!!!

Thanks! I've just edited the entry.

tietotesthyd
30th April 2009, 08:23
Thanks! just now i edited and removed the password and email id!

tietotesthyd
30th April 2009, 08:25
Yes i inherited QHttp Class. Actually i am checking the QHttpResponseHeader.

Please look at below Response:

reply Status Code = 400
Reply Status Text = "HTTP/1.1 400 Bad Request
Content-Type: text/html
Date: Thu, 30 Apr 2009 07:15:21 GMT
nnCoection: close
Content-Length: 39

tietotesthyd
30th April 2009, 08:25
Thanks for quick response.!:)

e8johan
30th April 2009, 08:27
I believe that QHttp not supports HTTPS. Have you looked at QNetworkAccessManager.

tietotesthyd
30th April 2009, 08:32
Thans !:) but for http Requests also we are facing the same problem!

Have a look at below code...
QHttp *http = new QHttp();
http->setHost("api.myspace.com");

QHttpRequestHeader header("POST", "/request_token");

header.setContentType("application/x-www-form-urlencoded");


header.setValue("Host","http://api.myspace.com");

header.setValue("Authorization:", authenticationHeader);

http->request(header,reply);
where authentication header will contain
(QPair("Host","http://api.myspace.com") ,
QPair("Authorization",
"OAuth realm="http%3A%2F%2Fapi.myspace.com",
oauth_nonce="Tm6Ebh5qps13PFPc",
oauth_timestamp="1241075491",
oauth_consumer_key="XXXX",
oauth_signature_method="HMAC-SHA1",
oauth_version="1.0",
oauth_signature="XXX"") )

same kind of output it is giving..
reply Status Code = 400
Reply Status Text = "HTTP/1.1 400 Bad Request
Content-Type: text/html
Date: Thu, 30 Apr 2009 07:15:21 GMT
nnCoection: close
Content-Length: 39

what might be the problem? am i doing any thing wrong in url formation?

Thanks in advance
Regards,
developer