Results 1 to 10 of 10

Thread: need help for QHttp

  1. #1
    Join Date
    Jan 2006
    Posts
    46
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default need help for QHttp

    I tried wysota's example I found here http://www.qtcentre.org/forum/showpo...47&postcount=6

    Qt Code:
    1. QHttp http;
    2. QFile file("writetothisfile.txt");
    3. file.open(QIODevice::WriteOnly);
    4. http.get("http://www.ietf.org/iesg/1rfc_index.txt", &file);
    To copy to clipboard, switch view to plain text mode 

    but this only creates an empty writetothisfile.txt although http://www.ietf.org/iesg/1rfc_index.txt is not empty.

    Any idea what I'm doing wrong?

    thanx in advance

    Pat

  2. #2
    Join Date
    Jan 2006
    Location
    Kranj, Slovenia
    Posts
    34
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: need help for QHttp

    do you call file->close() right after the last line? Try call it using requestFinish(), so the app. will have the time to fill it...

    I have a question with the same topic. I have to search several pages. on the first page i have to find all the links and go to that pages to search for specific links. (the task is to list all the links on several blogs that are listed on the first page).
    I do that using QHttp. I download the first page and put all link/blogs on that page in a database. Then I try to do download the rest. But when the app. download first couple links it start's making empty files (that eventually gets some data). But then it stops with error: Found and error: Request Aborted.

    What happened?

    Regards,
    Luka

    Edit: The problem was in url.Path(), since it looks like QHttp can't handle URL like: "http://ww.example.com/?w=something". URL like "http://www.example.com/something" gives an empty file, but URL like "http://www.example.com/something/" works fine. URL like "http://www.example.com/index.php?com=something&id=same" gives only index.php without the content... Any solutions?
    Last edited by whoops.slo; 31st May 2006 at 21:54.

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

    Default Re: need help for QHttp

    Quote Originally Posted by patcito
    I tried wysota's example(...)
    The example doesn't work. You have to change:

    Qt Code:
    1. http.get("http://www.ietf.org/iesg/1rfc_index.txt", &file);
    To copy to clipboard, switch view to plain text mode 
    into
    Qt Code:
    1. http.setHost("www.ietf.org");
    2. http.get("/iesg/1rfc_index.txt", &file);
    To copy to clipboard, switch view to plain text mode 

    And remember to have an event loop active.

    Quote Originally Posted by whoops.slo
    I have a question with the same topic. I have to search several pages. on the first page i have to find all the links and go to that pages to search for specific links. (the task is to list all the links on several blogs that are listed on the first page).
    I do that using QHttp. I download the first page and put all link/blogs on that page in a database. Then I try to do download the rest. But when the app. download first couple links it start's making empty files (that eventually gets some data). But then it stops with error: Found and error: Request Aborted.
    Can we see the code which dispatches the requests?

  4. #4
    Join Date
    Jan 2006
    Location
    Kranj, Slovenia
    Posts
    34
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: need help for QHttp

    it's a bit messy and in slovene lang. but i hope you will be able to read it. The whole source is in the att.
    I'm still learning C++ as well as Qt and this is my first experiment with Qhttp so if you have any better solutions please let me know...

    Regards,
    Luka

    Edit: See my previous post... tnx
    Attached Files Attached Files
    Last edited by whoops.slo; 31st May 2006 at 21:54.

  5. #5
    Join Date
    Jan 2006
    Posts
    46
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: need help for QHttp

    Quote Originally Posted by wysota
    And remember to have an event loop active.
    what do you mean? could you give me an example please?

    thanx in advance

    Pat

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: need help for QHttp

    patcito:

    From QHttp docs:
    The class works asynchronously, so there are no blocking functions. If an operation cannot be executed immediately, the function will still return straight away and the operation will be scheduled for later execution. The results of scheduled operations are reported via signals. This approach depends on the event loop being in operation.
    QHttp::get() is one of QHttp's asynchronous functions. The function does not block and returns immediately. You'll get notified by signals when the request is started/finished/done..

    You don't have to care about this in a GUI application's main thread, as you already have an event loop running. But if you're using QHttp in another threads, you'll need to enter to an event loop in those threads.
    J-P Nurmi

  7. #7
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: need help for QHttp

    i have build a Gui_Wget whitout ui file...

    And i put to static libs .... to work on all file only include gui_wget.h and get file

    && look QProgressBar *progressDialog; + slot to next .... automatic...

    Have a look.....

    http://ciz.ch/svnciz/forms_shop/lib_...4/gui_wget.cpp
    http://ciz.ch/svnciz/forms_shop/lib_...qt4/gui_wget.h

    Make a list from file Qlist<qstringlist> and loop all

    Qt Code:
    1. void DB_Setup::Wget_File(int pos , QString u , QString f , QString user , QString pass )
    2. {
    3. /*file_put_contents_append("res.dat",QString( "Prendileo %1" ).arg( QString::number(pos)));*/
    4. get_file = new Gui_Wget(this);
    5. get_file->show();
    6. get_file->OrderGetUrl(u,f,user,pass); /* URL , Localfile , USER, PASS */
    7. connect( get_file, SIGNAL( ready_action() ), this, SLOT( incomming_next() ) );
    8. }
    To copy to clipboard, switch view to plain text mode 

  8. #8
    Join Date
    Jan 2006
    Posts
    46
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: need help for QHttp

    Quote Originally Posted by jpn
    you'll need to enter to an event loop in those threads.
    and how would I do this?

  9. #9
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: need help for QHttp

    My loop of file is a xml config file....

    and import remote db and file .... evry file open a popup show the progress from 0 to 100
    by 100 close and open the next .... you cann make a list by xml or sql...

    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <wget xmlns:cms="http://www.pulitzer.ch/2005/PuliCMS/1.0">
    3. <requestfile sqlurl="http://ppk.ciz.ch/qt_c++/db/customers.sql" localname="1sampledata.sql" />
    4. <requestfile sqlurl="http://ppk.ciz.ch/qt_c++/db/customers.sql" localname="2sampledata.sql" />
    5. </wget>
    To copy to clipboard, switch view to plain text mode 

    have a look on ... is a svn (subversion dir if you like...)

    http://ciz.ch/svnciz/forms_shop/forms_shop/db_setup.cpp

  10. #10
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: need help for QHttp

    Quote Originally Posted by patcito
    and how would I do this?
    int QThread::exec () [protected]
    J-P Nurmi

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.