Results 1 to 4 of 4

Thread: QHttp with localhost.

  1. #1
    Join Date
    Jun 2007
    Posts
    24
    Thanks
    11
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Unhappy QHttp with localhost.

    Qt version: 4.3.0
    Platform: Win, Unix and Mac
    Web server: IIS and Apache.
    ==================

    Qhttp with localhost appears to have a bug in Qt 4.3.0. All the signals are emitted with no errors but the content is not retrieved in temp.txt using this simple code snippet.

    QUrl url("http://localhost/temp/index.htm");
    http = new QHttp(this);
    http->setHost(url.host(), QHttp::ConnectionModeHttp);
    file = new QFile("c:/temp/temp.txt");
    if (!file->open(QIODevice::Truncate|QIODevice::WriteOnly)) {
    delete file;
    file = 0;
    return;
    }
    int httpGetId = http->get(url.path(), file);

    Even the responseHeaderReceived() signal is received correctly with something like this -

    "Response headerHTTP/1.1 200 OK
    server: Microsoft-IIS/5.1
    x-powered-by: ASP.NET"

    The browser is able to display this http://localhost/temp/index.htm

    If I replace localhost URL with any other URL, it works fine.
    When I searched through the archives and found a similar issue for QHttp with localhost with an older version of Qt.
    http://lists.trolltech.com/qt-intere...ad01082-0.html

    Is there a work around in QHttp for localhost requests? Please help
    Thanks for your help.

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QHttp with localhost.

    Do you handle the readyRead signal?
    Also, try adding the port to the URL:
    Qt Code:
    1. QUrl url("http://localhost:8080/temp/index.htm");
    To copy to clipboard, switch view to plain text mode 


    Regards

  3. #3
    Join Date
    Jun 2007
    Posts
    24
    Thanks
    11
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Smile Re: QHttp with localhost.

    Thanks for the quick reply.

    Tried with int httpGetId = http->get(url.path());
    and handling the readyRead() signal and it worked!!!

    Tried with http://localhost:8080/temp/index.htm but even that didn't work if I provide an IODevice* to the get() call
    The doc says readyRead signal is not emitted if you provide an IODevice* to the get() call since the content will get written to the pointer you provided during the get() call:
    int httpGetId = http->get(url.path(), file);
    The strange thing is it is working fine if the URL is on the www. For example, QUrl url("http://trolltech.com/developer");

    So, the work around is, as you suggested handling the readyRead() signal and not providing an IODevice*.

    Thanks a lot for your help.

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QHttp with localhost.

    The strange thing is it is working fine if the URL is on the www. For example, QUrl url("http://trolltech.com/developer");
    Oh, OK then.

    Regards

  5. The following user says thank you to marcel for this useful post:

    William Wilson (30th June 2007)

Similar Threads

  1. new QHttp() Error
    By fengtian.we in forum Qt Programming
    Replies: 7
    Last Post: 6th October 2010, 17:56
  2. From QHttp to QHttp over SSL
    By Nyphel in forum Newbie
    Replies: 1
    Last Post: 3rd July 2007, 10:41
  3. QHttp download file problem.
    By fengtian.we in forum Qt Programming
    Replies: 12
    Last Post: 12th June 2007, 09:39
  4. QHttp Problem
    By musaulker in forum Newbie
    Replies: 4
    Last Post: 29th March 2007, 00:40
  5. how to use QHttp inside QThread in Qt3
    By alusuel in forum Qt Programming
    Replies: 3
    Last Post: 14th July 2006, 11:19

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.