Results 1 to 5 of 5

Thread: Qhttp::request(...) method and GET request

  1. #1
    Join Date
    Mar 2006
    Posts
    8
    Thanks
    1
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qhttp::request(...) method and GET request

    It looks like Qhttp::request(const QHttpRequestHeader &header, QIODevice *data, QIODevice *to)
    method does not send request parameters for GET request.

    Method Qhttp::request(header,data ...) sends a request type defined in header.
    And this can be POST,GET etc.

    Qhttp::request(header,data ...) should send request parameters as data variable. It is OK for POST.
    But it does not send it for GET

    I do not want to use Qhttp::get() method because I need to send a special defined request header to server.

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

    Default Re: Qhttp::request(...) method and GET request

    What parameters do you mean? You mean the query string? (?xxx=yyy&aaa=bbb) For get requests the query string is part of the path.

  3. #3
    Join Date
    Mar 2006
    Posts
    8
    Thanks
    1
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qhttp::request(...) method and GET request

    Yes, I mean the query string (?xxx=yyy&aaa=bbb) that is a part of path

    But there is NO path variabel in Qhttp::request()
    Qhttp::request (QHttpRequestHeader& header, QIODevice* data, QIODevice* to)

    and this is a problem!

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qhttp::request(...) method and GET request

    Quote Originally Posted by mikhailt
    But there is NO path variabel in Qhttp::request()
    Because it's inside QHttpRequestHeader:
    QHttpRequestHeader::QHttpRequestHeader ( const QString & method, const QString & path, int majorVer = 1, int minorVer = 1 )
    Constructs a HTTP request header for the method method, the request-URI path and the protocol-version majorVer and minorVer.

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

    Zmrca (26th April 2010)

  6. #5
    Join Date
    Mar 2006
    Posts
    8
    Thanks
    1
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qhttp::request(...) method and GET request

    jacek yes exactly!
    I have found the solution!

    When the custom request header is being constructed for GET request,
    then all request parameters must be added there (to Path).
    As a string like "?aaa=123&ccc=456"

    QString strPath = RealURLPath;
    if (GET == RequestType) Path += "?aaa=123&ccc=456";
    QHttpRequestHeader* pHeader = new QHttpRequestHeader(RequestType, Path);

    It should not be done for POST request.

    Then we can send both POST and GET requests with custom header and request parameters through Qhttp::request() method.

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.