Results 1 to 9 of 9

Thread: QHttp Header formation -reg

  1. #1
    Join Date
    Apr 2009
    Posts
    5
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default 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
    Last edited by tietotesthyd; 30th April 2009 at 08:22.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QHttp Header formation -reg

    Go on, REMOVE THE PASSWORD!!!

  3. #3
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default 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.

  4. #4
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QHttp Header formation -reg

    Quote Originally Posted by Lykurg View Post
    Go on, REMOVE THE PASSWORD!!!
    Thanks! I've just edited the entry.

  5. #5
    Join Date
    Apr 2009
    Posts
    5
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QHttp Header formation -reg

    Thanks! just now i edited and removed the password and email id!

  6. #6
    Join Date
    Apr 2009
    Posts
    5
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default 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

  7. #7
    Join Date
    Apr 2009
    Posts
    5
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QHttp Header formation -reg

    Thanks for quick response.!

  8. #8
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QHttp Header formation -reg

    I believe that QHttp not supports HTTPS. Have you looked at QNetworkAccessManager.

  9. #9
    Join Date
    Apr 2009
    Posts
    5
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default 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

Similar Threads

  1. How to edit Horizontal Header Item in QTableWidget
    By ioannis in forum Qt Programming
    Replies: 6
    Last Post: 5th March 2013, 18:50
  2. Howto : Header and Footers
    By pshah.mumbai in forum Qt Programming
    Replies: 0
    Last Post: 29th October 2008, 15:32
  3. How to customize horizontal header (diagonal header view)
    By vairamuthu.g in forum Qt Programming
    Replies: 4
    Last Post: 4th September 2008, 15:59
  4. From QHttp to QHttp over SSL
    By Nyphel in forum Newbie
    Replies: 1
    Last Post: 3rd July 2007, 10:41
  5. Replies: 0
    Last Post: 10th November 2006, 13:46

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.