Results 1 to 8 of 8

Thread: QHttp "PUT METHOD" QT Problem File Upload. RFC 2616

  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 "PUT METHOD" QT Problem File Upload. RFC 2616

    Why QHttp can not upload file on fast PUT Method?

    bytes 0 send incomming I have other script written on libcurl and runnig only on Window...
    I like make this Put Method avaiable to all 3 os...

    How i find the Bug?... on server is not required user or pass.... (only a valid cookie and libbcurl recive it ok...)

    server say only:

    <h1>Request Entity Too Large</h1>
    The requested resource<br />/info.php<br />
    does not allow request data with PUT requests, or the amount of data provided in
    the request exceeds the capacity limit.

    - bytes 0 send incomming </pa



    Qt Code:
    1. /* class QCurl public */
    2. void StartPutFile()
    3. {
    4. wwwput = new QHttp();
    5. wwwput->setUser("","");
    6. connect(wwwput, SIGNAL(requestFinished(int, bool)), this, SLOT(httpRequestFinished(int, bool)));
    7. connect(wwwput, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)), this, SLOT(readResponseHeader(const QHttpResponseHeader &)));
    8. }
    9. /* RFC 2616 */
    10. /* class QCurl public Http PUT Method */
    11. int Sender( QString beamupfile , QString posturl , QString LogFileapps )
    12. {
    13. QFileInfo beamfaq(beamupfile);
    14. QString dateiName = beamfaq.fileName();
    15. QUrl url(posturl);
    16. wwwput->setHost(url.host(), 80);
    17. logFile = new QFile(LogFileapps);
    18. logFile->open(QIODevice::ReadWrite);
    19. putFile = new QFile(beamupfile);
    20. putFile->open(QIODevice::ReadOnly);
    21. qint64 sizeallow = putFile->size();
    22. QHttpRequestHeader header("PUT", url.path(),1,1); /* header */
    23. header.setValue("Host", url.host());
    24. header.setValue("Connection", "keep-alive");
    25. header.setValue("User-Agent", WEBAGENTNAME );
    26. header.setValue("Content-length",QString::number(sizeallow));
    27. qDebug() << "### beamfaq.size() " << sizeallow;
    28. putid = wwwput->request(header, putFile, logFile);
    29. return putid;
    30. }
    To copy to clipboard, switch view to plain text mode 



    Qt Code:
    1. /* the server script work on libcurl PUT METHOD only window! and large file go up / Mac=no / Linux=no*/
    2. <?php
    3. if ($_SERVER['REQUEST_METHOD'] == "PUT") {
    4. $content = file_get_contents("php://input");
    5. $kb=file_put_contents(date("U")."_aa.pdf",$content);
    6. header('Content-Type: text/xml; charset=utf-8');
    7. echo "\n";
    8. print '<parsererror xmlns="http://www.mozilla.org/newlayout/xml/parsererror.xml">';
    9. print $_SERVER['HTTP_USER_AGENT']." - bytes ".$kb." send incomming ";
    10. print '</parsererror>';
    11. exit;
    12. }
    13.  
    14. /*
    15.   curl_easy_setopt(curl_handle, CURLOPT_URL, sendurlwww );
    16.   curl_easy_setopt(curl_handle, CURLOPT_UPLOAD , TRUE );
    17.   curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, TRUE);
    18.   curl_easy_setopt(curl_handle, CURLOPT_PUT , TRUE);
    19.   curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT , 60 );
    20.   curl_easy_setopt(curl_handle, CURLOPT_COOKIEJAR, xwcookiefile );
    21.   curl_easy_setopt(curl_handle, CURLOPT_COOKIEFILE, xwcookiefile );
    22.   curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "QT4 / PPK_W @ciz.ch" );
    23.   curl_easy_setopt(curl_handle,CURLOPT_STDERR , logfile );
    24.   curl_easy_setopt(curl_handle,CURLOPT_INFILE , beamupfile );
    25.   curl_easy_setopt(curl_handle,CURLOPT_INFILESIZE , des.size());
    26.   */
    27. ?>
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 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 "PUT METHOD" QT Problem File Upload. RFC 2616

    I don't see a bug in Qt. Put works fine for me. Where do you see the bug anyway? It is the server which emits the error, not the client. I'd look for the bug in your code and not QHttp code (maybe "sizeallow" is incorrect? You're not checking for errors anywhere in your code).

  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 "PUT METHOD" QT Problem File Upload. RFC 2616

    Quote Originally Posted by wysota View Post
    I don't see a bug in Qt. Put works fine for me. Where do you see the bug anyway? It is the server which emits the error, not the client. I'd look for the bug in your code and not QHttp code (maybe "sizeallow" is incorrect? You're not checking for errors anywhere in your code).
    Yes by me running only on window now ... sizeallow comming from QFileInfo size()...
    Problem is this code not work on Mac Tiger Untested on Linux....

    I suppose Header is bad! PUT require a HTTP 1.1 Header .... is this here incomlete? to PUT method...

    Qt Code:
    1. QHttpRequestHeader header("PUT", url.path(),1,1); /* header */
    2. header.setValue("Host", url.host());
    3. header.setValue("Connection", "keep-alive");
    4. header.setValue("User-Agent", "Clientt XX");
    5. header.setValue("Content-length",QString::number(sizeallow)); /* QFileInfo size(). */
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 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 "PUT METHOD" QT Problem File Upload. RFC 2616

    Does
    Qt Code:
    1. putFile->open(QIODevice::ReadOnly);
    To copy to clipboard, switch view to plain text mode 
    return true?
    Does
    Qt Code:
    1. qint64 sizeallow = putFile->size();
    To copy to clipboard, switch view to plain text mode 
    return valid size?
    Does
    Qt Code:
    1. header.toString()
    To copy to clipboard, switch view to plain text mode 
    return a correct http header?

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

    patrik08 (25th October 2006)

  6. #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 "PUT METHOD" QT Problem File Upload. RFC 2616

    Is Work :-) : super ......

    i comment out

    ///////header.setValue("Content-length",QString::number(sizeallow));

    file size value .... and is incomming....

    & log file say ...

    ....> bytes 4614 send incomming </.....

    now i test on mac & linux... tanks...

    The PUT Upload is faster as POST .... and easy ... now if QT4 can accept cookie i remove my libcurl ...

    Why cookie? client send a small post form + file info mime ecc... to -> server:
    server send a cookie ticket to -> client & client is allow to insert PUT file nrxxxx to next 30 min. how QT can learn Cookie management?


    Qt Code:
    1. void StartPutFile()
    2. {
    3. wwwput = new QHttp();
    4. wwwput->setUser("","");
    5. connect(wwwput, SIGNAL(requestFinished(int, bool)), this, SLOT(httpRequestFinished(int, bool)));
    6. connect(wwwput, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)), this, SLOT(readResponseHeader(const QHttpResponseHeader &)));
    7. }
    8. /* RFC 2616 */
    9. /* class QCurl public Http PUT Method */
    10. int Sender( QString beamupfile , QString posturl , QString LogFileapps )
    11. {
    12. QFileInfo beamfaq(beamupfile);
    13. QString dateiName = beamfaq.fileName();
    14. QUrl url(posturl);
    15. wwwput->setHost(url.host(), 80);
    16. logFile = new QFile(LogFileapps);
    17. logFile->open(QIODevice::ReadWrite);
    18. putFile = new QFile(beamupfile);
    19. putFile->open(QIODevice::ReadOnly);
    20. qint64 sizeallow = putFile->size();
    21. QHttpRequestHeader header("PUT", url.path(),1,1); /* header */
    22. header.setValue("Host", url.host());
    23. header.setValue("Connection", "keep-alive");
    24. /////header.setValue("User-Agent", WEBAGENTNAME );
    25. ///////header.setValue("Content-length",QString::number(sizeallow));
    26. qDebug() << "### header.toString() " << header.toString();
    27. qDebug() << "### beamfaq.size() " << sizeallow;
    28. putid = wwwput->request(header, putFile, logFile);
    29. return putid;
    30. }
    To copy to clipboard, switch view to plain text mode 

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 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 "PUT METHOD" QT Problem File Upload. RFC 2616

    Quote Originally Posted by patrik08 View Post
    how QT can learn Cookie management?
    Just set the "Cookie" header with the proper content of the cookie in the QHttp object.

  8. #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: QHttp "PUT METHOD" QT Problem File Upload. RFC 2616

    Quote Originally Posted by wysota View Post
    Just set the "Cookie" header with the proper content of the cookie in the QHttp object.
    Server can send Cookie but client QT4 cant not read....! I dont say how? (only libcurl can..)
    If I send a header fill ... "Filename" user & ..... Client not say a relative path from server to save the PUT file upload?
    I make a simpled handshake client & server and transmit to client a cookie contenent the relative path to save...

    Qt Code:
    1. <?php
    2. define ("SOTIME",date("l dS of F Y h:i:s A"));
    3. /* incomming file */
    4. if ($_SERVER['REQUEST_METHOD'] == "PUT") {
    5. $kb = 0;
    6. $nrfile = $_COOKIE["UNIXCIZNUMMER"]; /* cms file NR. (Unixtime NULL nr. )*/
    7. $dirappend = $_COOKIE["TIPERMISO"]; /* path & file name cookie from client */
    8. if ( strlen($nrfile) > 9 ) {
    9. $apie = new CMS_Page($nrfile.'-it',false); /* false not write operation */
    10. $Pathw = $apie->Assign_File(); /* file nummer index must exist! */
    11. if (is_file($Pathw)) {
    12. $destcoso = $apie->Assign_Path().DIRECTORY_SEPARATOR.$dirappend;
    13. $content = file_get_contents("php://input"); /* grab file */
    14. $kb=file_put_contents($destcoso,$content);
    15. }
    16. }
    17. if ($kb > 3) {
    18. setcookie ("ARIVOSSTRUEDATACIZ",SOTIME, time() - 3600); /* confirm success ! */
    19. }
    20. header('Content-Type: text/xml; charset=utf-8');
    21. echo "\n";
    22. print '<parsererror xmlns="http://www.mozilla.org/newlayout/xml/parsererror.xml">';
    23. print $destcoso." - ".$_COOKIE["UNIXCIZNUMMER"] . "\n\n\n";
    24. print $_SERVER['HTTP_USER_AGENT']." - bytes ".$kb." send ".$_COOKIE["ARIVOSSTRUE"];
    25. print '</parsererror>';
    26. exit;
    27. }
    28. ?>
    To copy to clipboard, switch view to plain text mode 

    After client as incomming the cookie confir success .. i delete the device ...

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 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 "PUT METHOD" QT Problem File Upload. RFC 2616

    Quote Originally Posted by patrik08 View Post
    Server can send Cookie but client QT4 cant not read....!
    Why not?

    It can read any header therefore I don't see a problem reading "set-cookie" header, you just need to access the response object through QHttp interface.

    If I send a header fill ... "Filename" user & ..... Client not say a relative path from server to save the PUT file upload?
    I don't have a slightest idea what you mean

    Qt Code:
    1. <?php
    2. define ("SOTIME",date("l dS of F Y h:i:s A"));
    3. ...
    4. ?>
    To copy to clipboard, switch view to plain text mode 
    Are these snippets of yours really necessary? They are completely irrelevant and you keep pasting them in each post you write. We are very happy you can produce PHP code and you wish to transfer some part of the functionality to a Qt based system, but I don't see a reason for flooding the forum with irrelevant php code. Don't be mad, I'm just doing my moderator job

Similar Threads

  1. File Binary Upload QHttp find the bug/s
    By patrik08 in forum Qt Programming
    Replies: 13
    Last Post: 10th June 2008, 07:51

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.