QHttp Header formation -reg
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
Re: QHttp Header formation -reg
Go on, REMOVE THE PASSWORD!!!
Re: QHttp Header formation -reg
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 QHttpResponseHeaderthat you get from the responseHeaderReceived signal, i.e. not looking at the contents of arr.
Re: QHttp Header formation -reg
Quote:
Originally Posted by
Lykurg
Go on, REMOVE THE PASSWORD!!!
Thanks! I've just edited the entry.
Re: QHttp Header formation -reg
Thanks! just now i edited and removed the password and email id!
Re: QHttp Header formation -reg
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
Re: QHttp Header formation -reg
Thanks for quick response.!:)
Re: QHttp Header formation -reg
I believe that QHttp not supports HTTPS. Have you looked at QNetworkAccessManager.
Re: QHttp Header formation -reg
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