PDA

View Full Version : using Qhttp with www(x) sites



importantman
29th March 2006, 14:05
my current project involves using the qhttp class or qt-3.4 to connect to various sites, which worked fine until it encountered a request for a site like 'www3.someurl.com'

It kicked back an error message that it couldn't find the host. :eek:

how do you connect to www(x) sites ? :confused:

Thanks in advance

jacek
29th March 2006, 14:07
Name of the server shouldn't have any impact on QHttp. Could you provide any example of non working URL?

importantman
29th March 2006, 14:13
www63.hattrick.org

just don't spam or DNS them !

jacek
29th March 2006, 14:46
Does your application handle redirects?


code: 302, reason: Object moved
<head><title>Object moved</title></head>
<body><h1>Object Moved</h1>This object may be found <a HREF="/Common/default.asp">here</a>.</body>

wysota
29th March 2006, 15:41
www63.hattrick.org

just don't spam or DNS them !

Don't worry, I used QHttp to connecto to HT successfully. Some hattrick servers become unresponsive from time to time.

importantman
29th March 2006, 22:11
Does your application handle redirects?

Hmmm, not sure. I check the header and see if I'm reciveing a redirect, though I'd assum that a host not found would mean I'm not getting so much as a header, but I will see...

wysota
29th March 2006, 22:17
Can you connect to that particular server using a web browser?

importantman
29th March 2006, 23:14
yes, I can.

importantman
31st March 2006, 03:08
hmmm...

maybe I am having problems because of syncing qhttp.

The download procedure requires a series of downloads, so
I was using this statement:

while(http.state() != QHttp::Unconnected){;}

so that my program flow could be one function, instead declaring a slot function for each download in the series. But that while loop isn't working. Any suggestions ?

jacek
31st March 2006, 10:28
QHttp needs a running event loop.

wysota
31st March 2006, 14:49
In short words, use signals and slots. For Hattrick I use the requestFinished slot and store a type of request along the request id. This way I know if I'm in a search-server, login, logout or download phase and can easily redirect to the appropriate method which handles the next phase.

importantman
31st March 2006, 15:35
> For Hattrick I use the requestFinished slot and store a type of request along the request id.

that's a good idea, better than changing signal/slot connections !!

(surprised someone here knows hattrick):cool:

btw: how do you enter quotes in this thing ?

and jacek: what is a running event loop ?

wysota
31st March 2006, 15:53
> For Hattrick I use the requestFinished slot and store a type of request along the request id.

that's a good idea, better than changing signal/slot connections !!

My first attempt was to change connections too (when I was still using Qt3), but after your post here I decided to change it in the new code (as I'm porting my HT app to Qt4) and thought this was much better idea. It took me about 15 minutes to implement the whole login process.


(surprised someone here knows hattrick):cool:
Hattrick is a big family. Over half a milion people use it.


btw: how do you enter quotes in this thing ? I don't understand. What quotes?

jacek
31st March 2006, 16:24
what is a running event loop ?
Event loop delivers events to objects. In Qt3 main event loop runs in the GUI thread (you start it when you invoke QApplication::exec()) and each time you open a modal dialog it creates its own temporary event loop.

If event loop isn't running, your application doesn't process events and all event-driven parts are not functioning: widgets don't redraw themselves, user can't interact with your GUI, QSockets don't emit signals and so on.

If you wait for something in a loop and you don't allow your application to process events (i.e. you block the event loop), it might occur that this loop is in fact an infinite loop.

importantman
3rd April 2006, 02:37
My first attempt was to change connections too (when I was still using Qt3), but after your post here I decided to change it in the new code (as I'm porting my HT app to Qt4) and thought this was much better idea. It took me about 15 minutes to implement the whole login process.


Well, I used the state variable idea, and tydied up something else, and I can now connect to the next page, and even recieve the security code (cookie), but when I ask for the next page I get only the time-out response.

Here's the cookie I get: ASPSESSIONIDSSSRBAQB=JMIGEOEDGPJOICJPBHBKGANJ;

And my connection string for the next site: getStr="/common/players.asp?outputType=XML&actionType=view";

I've tried pulling apart the cookie, but still no luck. Any suggestions ?


BTW: Is your application published?
BTW: How 'bout a friendly ?

wysota
3rd April 2006, 10:07
BTW: Is your application published?
Not yet. I don't have time to finish it because I'm answering Qt questions here at QtCentre ;)


BTW: How 'bout a friendly ?
Sure. But next week :)

As for the cookie, I just set the cookie exactly as I receive it (maybe it's better to move this conversation to CHPP forum on HT? :) ), I don't even look at its contents.

So in this case:
Set-cookie: ASPSESSIONIDSSSRBAQB=JMIGEOEDGPJOICJPBHBKGANJ;

importantman
3rd April 2006, 14:53
As for the cookie, I just set the cookie exactly as I receive it (maybe it's better to move this conversation to CHPP forum on HT? :) ), I don't even look at its contents.

So in this case:
Set-cookie: ASPSESSIONIDSSSRBAQB=JMIGEOEDGPJOICJPBHBKGANJ;

I tried the folks at the CHPP forum, but I think they all write in php.:rolleyes: One guy told me to try using only the second part of the cookie string ( and I think he meant the part after the '=', but I'm not sure, It didn't work anyway.)

Perhaps I have to have 'Set-cookie' instead of 'set-cookie' ? The header I recieve says 'set-cookie'. I'll try it anyway when I get home.

wysota
3rd April 2006, 16:18
No... My mistake... it should be "cookie:" not "set-cookie:".

importantman
4th April 2006, 00:12
Hey! It works!:D This is the last part of my program, all I have to do is write the mapping function (xml->sql) and I'm done. (at least with the first pre-release)

check out hdm.sourceforge.net sometime when I build the release!