[Qt-interest] QT power switch
luis navarro
luis.navarro at jro.igp.gob.pe
Mon Nov 30 19:47:36 CET 2009
Finally i get my objective. Thanks to everybody. Here is the code:
void MainWindow::useOUTLET(QString state,QString outlet){
QHttpRequestHeader req_head("GET","/outlet?"+outlet+"="+state);
req_head.setValue("Host","mypowerswitch");
req_head.setValue("Connection","keep-alive");
req_head.setValue("User-Agent=","QHTTP");
req_head.setValue("Accept-Charset","ISO-8859-1,UTF-8;q=0.7,*;q=0.7");
req_head.setValue("Cache-Control","no");
req_head.setValue("Accept-Language","de,en;q=0.7,en-us;q=0.3");
req_head.setValue("Cookie","DLILPC=\"jqu7JhA9bxXbGjm\"; Version=1;
Max-Age=0; Path=/");
http->setHost("mypowerswitch",QHttp::ConnectionModeHttp,80);
http->request(req_head);
}
2009/11/24 luis navarro <luis.navarro at jro.igp.gob.pe>
> Thanks for your advices. I was trying this code without good results. Can
> you give me a link where i can see some examples about how to handle the
> cookie and post request?
>
> void MainWindow::webPowerSwitch(){
>
> QHttpRequestHeader header("POST", "/outlet?1=ON");
>
> header.setValue("Host", "mypowerswitch");
>
> header.setValue("Username","user");
>
> header.setValue("password","xxxx");
>
> header.setContentType("application/x-www-form-urlencoded");
>
> http->setHost("mypowerswitch");
>
> http->request(header, turnONString.toUtf8());
> }
>
> 2009/11/24 Thiago Macieira <thiago at kde.org>
>
>> Em Terça-feira 24. Novembro 2009, às 08.30.35, Thiago Macieira escreveu:
>> > Em Terça-feira 24. Novembro 2009, às 01.31.02, luis navarro escreveu:
>> > > That's really a problem because i need this application. So for this
>> case
>> > > what can we do?
>> >
>> > Wait for the authenticationRequired signal and fill in the data that it
>> > requests.
>> >
>> > The other alternative is to fill in the form data and submit it. You can
>> do
>> > that via JavaScript or via QWebElement (4.6).
>>
>> A third alternative is to send a POST with the authentication data
>> directly,
>> as if you had clicked the Submit button in the form. That will probably
>> send a
>> cookie back to you, which you can use to send the next command.
>>
>> --
>> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
>> Senior Product Manager - Nokia, Qt Development Frameworks
>> PGP/GPG: 0x6EF45358; fingerprint:
>> E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
>>
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
>>
>
>
> --
> Atte.
> Luis Navarro Domínguez
> luis.navarro at jro.igp.gob.pe
> LISN Department
> Jicamarca Radio Observatory
> Geophysical Institute of Peru
> Apartado 13-0207
> Lima 13 - Peru
> Telf: (51)-1-3172313
> Fax: (51)-1-3172312
> http://jro.igp.gob.pe/
>
--
Atte.
Luis Navarro Domínguez
luis.navarro at jro.igp.gob.pe
LISN Department
Jicamarca Radio Observatory
Geophysical Institute of Peru
Apartado 13-0207
Lima 13 - Peru
Telf: (51)-1-3172313
Fax: (51)-1-3172312
http://jro.igp.gob.pe/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091130/d629c5e8/attachment.html
More information about the Qt-interest-old
mailing list