Results 1 to 11 of 11

Thread: Https POST Request

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    667
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    10
    Thanked 80 Times in 74 Posts

    Default Re: Https POST Request

    This is what I did

    Qt Code:
    1. connect(&http,SIGNAL(done(bool)),this,SLOT(httpDone(bool)));
    2. connect(&http,SIGNAL(readyRead(const QHttpResponseHeader &)),this,SLOT(readyRead(const QHttpResponseHeader &)));
    3.  
    4. http.setHost("www.google.com");
    5.  
    6. QString str = "Email=somename@gmail.com&Passwd=somepassword"
    7. "&service=cl&source=Gulp-CalGulp-1.05";
    8. QHttpRequestHeader header( "POST", "/accounts/ClientLogin") ;
    9. header.setValue("Host", "https://www.google.com") ;
    10. header.setContentType( "application/x-www-form-urlencoded" ) ;
    11. http.request(header,QVariant(str).toByteArray());
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void UpdateChecker::readyRead(const QHttpResponseHeader &header)
    2. {
    3. //QString str = header.reasonPhrase();
    4. result = QString(http.readAll().data());
    5. }
    To copy to clipboard, switch view to plain text mode 

    I got result as

    Qt Code:
    1. <HTML>
    2. <HEAD>
    3. <TITLE>Moved Temporarily</TITLE>
    4. </HEAD>
    5. <BODY BGCOLOR="#FFFFFF" TEXT="#000000">
    6. <H1>Moved Temporarily</H1>
    7. The document has moved <A HREF="https://https/accounts/ClientLogin">here</A>.
    8. </BODY>
    9. </HTML>
    To copy to clipboard, switch view to plain text mode 

    Probably Qt itself is generating this.

    Can you please give me some minimal example on how I encrypt the data and send ?

    Thanks a lot.

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    10
    Thanked 80 Times in 74 Posts

    Default Re: Https POST Request

    I did one more experiment. Here it is

    Qt Code:
    1. <html>
    2. <body>
    3. <form action="https://www.google.com/accounts/ClientLogin" method="post">
    4.  
    5. <input type="hidden" name="service" value="cl" />
    6. <input type="hidden" name="source" value="some-app-1.0" />
    7.  
    8. Email :
    9. <input type="text" name="Email" />
    10. <br/>
    11. Password:
    12. <input type="password" name="Passwd" />
    13. <br/>
    14. <input type="submit" name="Submit" value="Login">
    15.  
    16. </form>
    17. </body>
    18. </html>
    To copy to clipboard, switch view to plain text mode 

    The response to this was what google sends and this code works correctly.

    Isn't this similar to the code above?

    Maybe I have got the basics itself wrong.

    Please help.
    Thanks a lot

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Https POST Request

    The problem is that QHttp doesn't handle https (SSL). Without introducing the SSL layer you won't be able to send a https request.

Similar Threads

  1. X Error of failed request - on exit
    By VorosM in forum Newbie
    Replies: 3
    Last Post: 12th April 2006, 10:22

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
  •  
Qt is a trademark of The Qt Company.