Results 1 to 5 of 5

Thread: QHttp RFC Method PUT not work.

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

    Default QHttp RFC Method PUT not work.

    From subjekt ....

    If i Launch a Request PUT on http header not run! on QT4.3 beta
    return only unknow error....

    if i take my projekt ( http://sourceforge.net/projects/qt-webdav/ ) on qt4.2 can build and run ok on QT4.3beta can compile & run ... but can not upload file on method PUT..

    RFC Standard are GET,POST,PUT,OPTIONS,HEAD,DELETE
    http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

    Upload file on PUT having more speed as POST.......

    QHttp::state() stay 0 QHttp::Unconnected

    Anybody know this as Bug? or you have a Answer?


    Qt Code:
    1. int main(int argc, char* argv[])
    2. {
    3. QApplication app(argc, argv);
    4. qDebug() << "### start main ";
    5. PutSender *job = new PutSender(QUrl("http://www.qtcentre.org/"),"a.zip");
    6. return app.exec();
    7. }
    To copy to clipboard, switch view to plain text mode 

    Method PUT Upload ....

    Qt Code:
    1. #ifndef BASE_BUTTON_H
    2. #define BASE_BUTTON_H
    3.  
    4. #include <QString>
    5. #include <QDebug>
    6. #include <QObject>
    7. #include <QHttp>
    8. #include <QAbstractSocket>
    9. #include <QFileInfo>
    10. #include <QHttp>
    11. #include <QUrl>
    12. #include <QtGui>
    13. #include <QTimer>
    14.  
    15.  
    16. #if defined Q_WS_MAC
    17. #define WEBAGENTNAME "Mac QT4 / PPK_W @ciz.ch"
    18. #endif
    19. #if defined Q_WS_WIN
    20. #define WEBAGENTNAME "Windows QT4 / PPK_W @ciz.ch"
    21. #endif
    22. #if defined Q_WS_X11
    23. #define WEBAGENTNAME "Unix QT4 / PPK_W @ciz.ch"
    24. #endif
    25. typedef QMap<int, QStringList> cookiepam; /* cookie */
    26. typedef QMap<QString, QString> ParamVar; /* xml params store */
    27.  
    28. class PutSender : public QObject
    29. {
    30. Q_OBJECT
    31. /* #####################url#############uploadfiel#######*/
    32. public: PutSender( QUrl urigo , QString locfile )
    33. {
    34. urigoup = QUrl(urigo);
    35. davinfo = new QHttp();
    36. BeamUp = new QFile(locfile); /* upload file */
    37.  
    38. if (BeamUp->exists()) {
    39. //////byteArray.clear();
    40. //////BeamLog = new QBuffer(); /* buffer */
    41. //////BeamLog->setBuffer(&byteArray);
    42. ////////BeamLog->open(QIODevice::ReadWrite);
    43. logFile = new QFile("log.txt");
    44. logFile->open(QIODevice::ReadWrite);
    45. BeamUp = new QFile(locfile);
    46. BeamUp->open(QIODevice::ReadOnly);
    47. QHttpRequestHeader header("PUT", urigoup.path() ,1,1); /* header */
    48. header.setValue("Host",urigoup.host());
    49. header.setValue("User-Agent", WEBAGENTNAME );
    50. header.setValue("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7");
    51. header.setValue("Accept-Language", "it,de-de;q=0.8,it-it;q=0.6,en-us;q=0.4,en;q=0.2");
    52. header.setValue("Connection", "keep-alive");
    53. david = davinfo->request(header,BeamUp,logFile);
    54. qDebug() << "### david " << david;
    55. connect(davinfo, SIGNAL(dataSendProgress(int, int)), this, SLOT(SendStatus(int, int)));
    56. connect(davinfo, SIGNAL(stateChanged(int)), this, SLOT(State(int)));
    57. connect(davinfo, SIGNAL(requestStarted(int)), this, SLOT(Started(int)));
    58. Debugme();
    59.  
    60. } else {
    61. ErrorMSG("File upload not found!");
    62. }
    63. }
    64. protected:
    65. int david;
    66. QUrl urigoup;
    67. QHttp *davinfo;
    68. QFile *BeamUp;
    69. QFile *logFile;
    70. QBuffer *BeamLog;
    71. QByteArray byteArray;
    72.  
    73.  
    74. private:
    75. signals:
    76. public slots:
    77. void State( int a1 )
    78. {
    79. qDebug() << "### state " << a1;
    80. }
    81. void Started( int a1 )
    82. {
    83. qDebug() << "### strted " << a1;
    84. }
    85. void Debugme()
    86. {
    87. qDebug() << "### debug state 0/6 scala " << davinfo->state();
    88. qDebug() << "### error " << davinfo->error();
    89. QTimer::singleShot(1000, this, SLOT(Debugme()));
    90. }
    91.  
    92. void SendStatus( int tot , int stats )
    93. {
    94. qDebug() << "### status " << tot << "-" << stats;
    95. }
    96. void ErrorMSG( const QString message )
    97. {
    98. qDebug() << "### message " << message;
    99. }
    100.  
    101. };
    102.  
    103. #endif // BASE_BUTTON_H
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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 RFC Method PUT not work.

    Did you set the host in the QHttp object?

  3. #3
    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: QHttp RFC Method PUT not work.

    Quote Originally Posted by wysota View Post
    Did you set the host in the QHttp object?
    Yes original is it...

    the same problem is on my source ...

    http://sourceforge.net/project/showf...kage_id=222560

    to build i downgrade to :

    QMake version 2.01a
    Using Qt version 4.2.3 in D:\qt\lib

    the problem is only upload .. on qt4.3 beta ...
    https://qt-webdav.svn.sourceforge.ne...r/dav/davput.h

    i not tested on http://labs.trolltech.com/blogs/2007...30-rc1-is-out/

    Make yourself a free 5MB webdav account to test
    https://www.sharemation.com/xythoswf...action=newuser
    IMO: is not apache2 but header-responder comming...



    Qt Code:
    1. class PutSender : public QObject
    2. {
    3. Q_OBJECT
    4. /* #####################url#############uploadfiel#######*/
    5. public: PutSender( QUrl urigo , QString locfile )
    6. {
    7. urigoup = QUrl(urigo);
    8. davinfo = new QHttp();
    9. davinfo->setHost(urigoup.host(), 80);
    10. BeamUp = new QFile(locfile); /* upload file */
    11. starter = 0;
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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 RFC Method PUT not work.

    Could you provide a minimal compilable example reproducing the problem?

  5. #5
    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: QHttp RFC Method PUT not work.

    Quote Originally Posted by wysota View Post
    Could you provide a minimal compilable example reproducing the problem?
    Hurra sorry i found the bug on write && rewrite the minimal example on a single file main.cpp......

    on QUrl correct is : QUrl("http://user:pass@www.sharemation.com/ppkciz/")

    QUrl("http://user:pass@hostname.com/path/")


    correct is...

    Qt Code:
    1. QApplication app(argc, argv);
    2. std::cout << "Main start Process ID:" << getpid() << std::endl;
    3. /* User ID:" << getuid() unix */
    4. /* Get Option from remote server */
    5. HTTP_option *job = new HTTP_option(QUrl("http://user:pass@www.sharemation.com/ppkciz/"));
    To copy to clipboard, switch view to plain text mode 


    well on a other projekt i use :

    mysql://user:pass@host:portnr/database to pass argument on main argv[] ....

    and i replace qurl path ///

    so QString dbase = dns.path().replace("/","");

    to become the correct database name... als path...

    i confused the path after whitout // on a copy & paste function

    the QUrl is great to pass argument and scheme but must work exact!....





    Qt Code:
    1. QUrl dns(mysqlshema);
    2. QString dbase = dns.path().replace("/","");
    3. QStringList drivers = QSqlDatabase::drivers();
    4. if (!drivers.contains("QMYSQL")) {
    5. std::cout << "### Load QMYSQL Driver Fail!." << std::endl;
    6. return;
    7. }
    8.  
    9. db0 = QSqlDatabase::addDatabase("QMYSQL");
    10. db0.setHostName(dns.host());
    11. db0.setDatabaseName(dbase);
    12. db0.setUserName(dns.userName());
    13. db0.setPassword(dns.password());
    14.  
    15. if (dns.port() > 0) {
    16. db0.setPort(dns.port());
    17. }
    18.  
    19. if (!db0.open()) {
    20. ...........
    To copy to clipboard, switch view to plain text mode 

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.