Qt supports HTTPS connections

Source: Internet
Author: User

/// Processing Description: configure the corresponding port and Conf. setprotocol (qssl: SSLv3 );

//// And handle errors (when connecting to the webpage, an unreliable connection or untrusted connection will be prompted. In this case, ignore and continue)

//// Processing of the following primary tasks: In in

Qnetworkaccessmanager * networkmng; // connection

Qnetworkreply * reply; // Network Response

Connect (networkmng, signal (sslerrors (qnetworkreply *, const qlist <qsslerror> &)),
This, slot (slotsslerrordeal (qnetworkreply *, const qlist <qsslerror> &)));

Qurl urltemp (m_serverurl );
Urltemp. setport (ihttpsport); // set the port number here

Qnetworkrequest requesttemp (urltemp );
Requesttemp. setheader (qnetworkrequest: contenttypeheader, "application/zip ");
Requesttemp. setrawheader ("FILENAME", logfile. toutf8 ());

Qsslconfiguration conf = requesttemp. sslconfiguration ();
Conf. setprotocol (qssl: SSLv3 );
Requesttemp. setsslconfiguration (CONF );

Reply = mp_networkmng-> post (requesttemp, l_content );

Connect (reply, signal (finished ()),
This, slot (slotuploadlogfinished ()));

// Waiting for upload
Int waitcount = 1;
While (waitcount)
{
Sleep (10000 );
Waitcount --;
}

//// End

////// The error handling is as follows:

Void cmyclass: slotsslerrordeal (qnetworkreply * reply, const qlist <qsslerror> & errors)
{

Qlist <qsslerror >:: const_iterator conit = errors. Begin ();
While (conit! = Errors. End ())
{
Qstring stemp = (* conit). errorstring ();
Writetestdebuglog (stemp); // print the Error Log
Qdebug () <(* conit). errorstring ();
++ Conit;
}
Reply-> ignoresslerrors ();

Return;
}

/// // End

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.