Results 1 to 14 of 14

Thread: QHttp get unparsed php file from WebDav! and same file firefox parse Ok.

  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

    Angry QHttp get unparsed php file from WebDav! and same file firefox parse Ok.

    I have on server a alias dir called /webdav and other real dir called /setting Password protect from ldapserver alias webdav is password protected on same ldap...

    a request to /setting/index.php?lastupdate=1414141414 (unixtime) from firefox parse this file ....

    the same request from qt QHttp download the plain text index.php and not the attached sqldump ??? why???

    I have spend much time & money to make the Http request with qt in place of libcurl and now the same QHttp give me a big invoice


    QHttp download this file as text! firefox no! (get the file sql ...)
    Qt Code:
    1. <?php
    2. header("Content-Type: text/plain");
    3. header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    4. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Datum in der Vergangenheit
    5. if(!defined('DIR_SEP')) {
    6. define('DIR_SEP', DIRECTORY_SEPARATOR);
    7. }
    8. print(file_get_contents(dirname(__FILE__).DIR_SEP."CURRENT_OBJEKT_3.sql"));
    9. /* .... update command on server ..... */
    10. ?>
    To copy to clipboard, switch view to plain text mode 


    my qt friend.... action
    full file http://ciz.ch/svnciz/_STATIC_LIBS_QT...k/gui_wget.cpp
    Qt Code:
    1. http = new QHttp(this);
    2. stopButton->setEnabled(true);
    3. http->setHost(urls.host(),80);
    4. http->setUser( current_user , current_pass );
    To copy to clipboard, switch view to plain text mode 

    apache 2 setting only webdaw dir ForceType text/plain
    Qt Code:
    1. Alias /webdav/ /home/webdav/angry/
    2. <Location /webdav>
    3. DirectoryIndex webdavnone.html
    4. AuthType Basic
    5. AuthLDAPAuthoritative On
    6. AuthName "Explorer"
    7. AuthLDAPURL ldap://195.90.211.54:389/ou=webdav,dc=box,dc=ciz,dc=ch?uid?sub
    8. require valid-user
    9. DAV On
    10. ### to show php as text on browser ####
    11. ForceType text/plain
    12. SetEnv redirect-carefully
    13. <Limit PUT POST DELETE PROPFIND PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
    14. require user angry
    15. </Limit>
    16. </Location>
    To copy to clipboard, switch view to plain text mode 
    Last edited by patrik08; 20th June 2006 at 20:32.

  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 get unparsed php file from WebDav! and same file firefox parse Ok.

    I'm not sure if I understood you right. You mean you get different file contents depending on whether you access the location from firefox and QHttp? If so, then you have an error in your webserver configuration. QHttp just sends a request for a file, it doesn't do anything *magic*. And what exactly do you mean by "parsing"? QHttp doesn't do any parsing, it just fetches a block of data, it's not a web browser.

  3. #3
    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 get unparsed php file from WebDav! and same file firefox parse Ok.

    Use a network sniffer (like Ethereal) to check if QHttp requests differ from those issued by Firefox, but most likely there's something wrong with your Apache configuration.

  4. #4
    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 get unparsed php file from WebDav! and same file firefox parse Ok.

    Quote Originally Posted by jacek
    Use a network sniffer (like Ethereal) to check if QHttp requests differ from those issued by Firefox, but most likely there's something wrong with your Apache configuration.
    If i remove the line ( #######ForceType text/plain ) qt parse the php file.... .
    from /webdav alias ...but now problem .... i find parsed php file on my Hard-Drive and can not edit... on disk !!! .

    [ less +F webdavaccess.log ] i found ipclient GET /setting/index.php HTTP/1.1 "_" "_" no user agent

    QT make PUT & GET as same method!

    This is a BUG ...

    I make a extra alias domain to qt to resolve problem.....

    Qt Code:
    1. <Location /webdav>
    2. DirectoryIndex webdavnone.html
    3. AuthType Basic
    4. AuthLDAPAuthoritative On
    5. AuthName "Explorer"
    6. AuthLDAPURL ldap://195.90.211.54:389/ou=webdav,dc=box,dc=ciz,dc=ch?uid?sub
    7. require valid-user
    8. DAV On
    9. #######ForceType text/plain
    10. SetEnv redirect-carefully
    11. <Limit PUT POST DELETE PROPFIND PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
    12. require user client
    13. </Limit>
    14. </Location>
    To copy to clipboard, switch view to plain text mode 

  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 get unparsed php file from WebDav! and same file firefox parse Ok.

    The same url /setting/index.php is parsed by libcurl and take the sql dump file...

    The server take PUT DELETE PROPFIND PROPPATCH MKCOL COPY MOVE LOCK UNLOCK method on port 80 + AuthType Basic to webdav server hardisk....

    Webdav is the same protocoll as subversion http://subversion.tigris.org/ commit
    and file is evry time served on plain text ... and binary no....


    and GET POST port 80 to normal to human browser + AuthType Basic on/off

    On libcurl http://curl.haxx.se/ whit this simple code the file index.php is parsed!
    & QT plain/text ..... i suppose the server wand a user agent....

    Qt Code:
    1. /* return file contenets as qstring */
    2. QString Gui_Setting::file_get_contents( QString fullFileName )
    3. {
    4. QString inside = "";
    5. if (fullFileName.contains("https://", Qt::CaseInsensitive)) {
    6. /* not build in on window only mac & linux*/
    7. return inside;
    8. }
    9.  
    10.  
    11. xdcookiefile = QString( "%1biscotti.html" ).arg( WORK_CACHEDIR );
    12. xml_export_file = QString( "%1_xml_export.xml" ).arg( WORK_CACHEDIR );
    13. wwwnetfile = QString( "%1wwwfull.html" ).arg( WORK_CACHEDIR );
    14.  
    15. if (IsNetFile( fullFileName ) )
    16. {
    17. qt_unlink(wwwnetfile);
    18. /*QString xgeturl = fullFileName; http://shop.ecoplanet.ch/info.php */
    19. QByteArray lop = wwwnetfile.toAscii();
    20. char *localfile = lop.data();
    21. QByteArray der = xdcookiefile.toAscii();
    22. char *xwcookiefile = der.data();
    23. QByteArray ba = fullFileName.toAscii();
    24. char *url = ba.data();
    25. qDebug() << "### entra save to "<< localfile;
    26. qDebug() << "### get url "<< url;
    27. CURL *curl_handle;
    28. FILE *outfile;
    29. curl_global_init(CURL_GLOBAL_ALL);
    30. curl_global_init(CURL_GLOBAL_ALL);
    31. curl_handle = curl_easy_init();
    32. outfile = fopen(localfile, "w");
    33.  
    34. if (outfile!=NULL) {
    35. /* CURLOPT_COOKIE and must have CURLOPT_COOKIEJAR char * (file to write same as php) */
    36. curl_easy_setopt(curl_handle, CURLOPT_URL, url);
    37. curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, TRUE);
    38. curl_easy_setopt(curl_handle, CURLOPT_COOKIEJAR, xwcookiefile );
    39. curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION , 1);
    40. curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS , 2);
    41. curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT , 15 );
    42. curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, _USER_AGENT_CURL_APPS );
    43. curl_easy_setopt(curl_handle, CURLOPT_FILE, outfile);
    44.  
    45. if (curl_easy_perform(curl_handle)==CURLE_OK) {
    46. fclose(outfile);
    47.  
    48. QFile filecurl(wwwnetfile);
    49. if (filecurl.exists()) {
    50. if (filecurl.open(QFile::ReadOnly | QFile::Text)) {
    51. inside =filecurl.readAll();
    52. filecurl.close();
    53. if (inside.size() > 1) {
    54. curlerrormsg = "";
    55. qt_unlink(wwwnetfile);
    56. }
    57. }
    58. }
    59.  
    60. } else {
    61. curlerrormsg = "Error time out to get remote file";
    62. }
    63. }
    64. /* return grab result from local file */
    65. return inside;
    66. }
    67.  
    68.  
    69.  
    70.  
    71. /* ok is a fake normal local file init ..... */
    72. QFile file(fullFileName);
    73. if (file.exists()) {
    74. if (file.open(QFile::ReadOnly | QFile::Text)) {
    75. inside =file.readAll();
    76. file.close();
    77. if (inside.size() > 1) {
    78. curlerrormsg = "";
    79. }
    80. }
    81. }
    82.  
    83. return inside;
    84. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    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 get unparsed php file from WebDav! and same file firefox parse Ok.

    Could you explain what you mean by "parsed" in this context? Did you mean "interpreted"? It's the webserver which interprets php scripts, Qt doesn't have anything to do with it. Maybe you shouldn't enforce text/plain encoding but try with text/html (or see what type does the php script return).

    BTW. Please don't post code irrelevant to the problem on the forum.

  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: QHttp get unparsed php file from WebDav! and same file firefox parse Ok.

    This file is not parsed apache send file as plain text as is...

    index.php
    php code
    Qt Code:
    1. <?php
    2. header("Content-Type: text/plain");
    3. header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
    4. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Datum in der Vergangenheit
    5. if(!defined('DIR_SEP')) {
    6. define('DIR_SEP', DIRECTORY_SEPARATOR);
    7. }
    8. print(file_get_contents(dirname(__FILE__).DIR_SEP."CURRENT_OBJEKT_3.sql"));
    9. /* other hidden php code update operatian ....*/
    10. ?>
    To copy to clipboard, switch view to plain text mode 



    and this file is parsed ... server apache module php interpret php module and
    read file CURRENT_OBJEKT_3.sql served

    index.php result ... php code up ...
    file text
    Qt Code:
    1. CREATE TABLE PAESI (ID INTEGER PRIMARY KEY,NOME TEXT,CODICE TEXT);
    2. INSERT INTO PAESI VALUES ('1','Italy','IT');
    3. INSERT INTO PAESI VALUES ('2','Germany','DE');
    4. INSERT INTO PAESI VALUES ('3','United Kingdom','GB');
    5. INSERT INTO PAESI VALUES ('4','USA','US');
    6. INSERT INTO PAESI VALUES ('6','Switzerland','CH');
    7. INSERT INTO PAESI VALUES ('7','Andorra','AD');
    8. INSERT INTO PAESI VALUES ('8','United Arab Emirates','AE');
    9. INSERT INTO PAESI VALUES ('9','Afghanistan','AF');
    10. INSERT INTO PAESI VALUES ('10','Antigua and Barbuda','AG');
    11. INSERT INTO PAESI VALUES ('11','Anguilla','AI');
    12. INSERT INTO PAESI VALUES ('12','Albania','AL');
    13. INSERT INTO PAESI VALUES ('13','Armenia','AM');
    14. INSERT INTO PAESI VALUES ('14','Netherlands Antilles','AN');
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: QHttp get unparsed php file from WebDav! and same file firefox parse Ok.

    do you want to download the php file with php code executed (instead of php code you want data that is a resoult of the execution of the php code)? if so try downloading a php file from other server. Just to test if there is a problem with your code or with the configuration on the server.

  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: QHttp get unparsed php file from WebDav! and same file firefox parse Ok.

    Quote Originally Posted by whoops.slo
    do you want to download the php file with php code executed (instead of php code you want data that is a resoult of the execution of the php code)? if so try downloading a php file from other server. Just to test if there is a problem with your code or with the configuration on the server.
    Logical ... i want to make a button to download the executed php to import 4 sqlite3 table and on the same request a class on server switsch to read modus and lock (a lock file 1kb) the web admin section... So other user can not admin this 4 table.... If the QT client close or upload this 4 table (update) ... unlock and delete this 1kb file.. (only unixtime inside).....

    [If i connect the qt client direct to mysql from server or odbc ... evry action is long..... and slow ... sqlite update 100 row on 0.01 sec...] -- [the file download on qt start is 3 seconds...] - [the upload is 1 second on mounted webdav disk...]
    I must make the download table on http only for window .... why the mounted webdav disk stay much time on cache.... Mac OSX mount read & write the mounted disk on realtime...
    On this method qt work fast ... same as Oracle DB....



    If the client not upload this 4 table .... on server a cron job delete this lock file if is older as 3 Hours....

    But i solved this qt bug whit RewriteCond and request go to /extraqtsetting/lastupdate/

    a not existing folder .... so qt can not make conflict PUT & GET to become webdav existing dir... and i can uncommend "ForceType text/plain" to not become executed php on my...mountet remote webdav hardisk.


    Qt Code:
    1. RewriteEngine on
    2. RewriteCond %{REQUEST_URI} !^/*index.php
    3. RewriteCond %{REQUEST_URI} !^/*robots.txt
    4. RewriteCond %{REQUEST_URI} !^/*favicon
    5. RewriteCond %{REQUEST_URI} !^/*editor/
    6. RewriteCond %{REQUEST_URI} !^/*user/
    7. RewriteCond %{REQUEST_URI} !^/*pic/
    8. RewriteCond %{REQUEST_URI} !^/*icons/
    9. RewriteRule ^/*(.+)$ ./index.php?path=$1 [QSA]
    To copy to clipboard, switch view to plain text mode 

  10. #10
    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 get unparsed php file from WebDav! and same file firefox parse Ok.

    Quote Originally Posted by patrik08
    apache 2 setting only webdaw dir ForceType text/plain
    Qt Code:
    1. Alias /webdav/ /home/webdav/angry/
    2. <Location /webdav>
    3. DirectoryIndex webdavnone.html
    4. AuthType Basic
    5. AuthLDAPAuthoritative On
    6. AuthName "Explorer"
    7. AuthLDAPURL ldap://195.90.211.54:389/ou=webdav,dc=box,dc=ciz,dc=ch?uid?sub
    8. require valid-user
    9. DAV On
    10. ### to show php as text on browser ####
    11. ForceType text/plain
    12. SetEnv redirect-carefully
    13. <Limit PUT POST DELETE PROPFIND PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
    14. require user angry
    15. </Limit>
    16. </Location>
    To copy to clipboard, switch view to plain text mode 
    IMO this configuration doesn't prohibit the use of GET method. It just requires a specific user for the other methods.

  11. #11
    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 get unparsed php file from WebDav! and same file firefox parse Ok.

    Quote Originally Posted by jacek
    IMO this configuration doesn't prohibit the use of GET method. It just requires a specific user for the other methods.
    this config is only to alias

    Get & Post method is default from apache ....
    <Location /webdav>

    The problem by qt QHttp.... wenn user & pass is set....
    this is 2 request ... first get normal (like 1000 of homepage)
    the 2 request qt send PUT user & pass to the request file...

    http://www.w3.org/Protocols/rfc2616/...c9.html#sec9.6 PUT
    http://www.w3.org/Protocols/rfc2616/...4.html#sec14.8 Authorization

  12. #12
    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 get unparsed php file from WebDav! and same file firefox parse Ok.

    Quote Originally Posted by patrik08
    The problem by qt QHttp.... wenn user & pass is set....
    this is 2 request ... first get normal (like 1000 of homepage)
    the 2 request qt send PUT user & pass to the request file...
    But what is exactly wrong with QHttp? Could you prepare a minimal compilable example that illustates the problem and intercept (using some network sniffer) requests sent by QHttp and Firefox and paste them here, so we can compare them?

  13. #13
    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 get unparsed php file from WebDav! and same file firefox parse Ok.

    Quote Originally Posted by jacek
    But what is exactly wrong with QHttp? Could you prepare a minimal compilable example that illustates the problem and intercept (using some network sniffer) requests sent by QHttp and Firefox and paste them here, so we can compare them?

    Ok i have the sample.....
    http://ppk.ciz.ch/mac_build/qhttp_qt.tar.bz2

    And now how configure etheral to read only tcp on port 80?

    this i read on firefox live ... header .......


    Qt Code:
    1. GET /setting/ HTTP/1.1
    2. Host: urlx.com
    3. User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; it-IT; rv:1.7.12) Gecko/20050919 Firefox/1.0.7
    4. Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
    5. Accept-Language: de-de,it;q=0.8,it-it;q=0.6,en-us;q=0.4,en;q=0.2
    6. Accept-Encoding: gzip,deflate
    7. Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    8. Keep-Alive: 300
    9. Connection: keep-alive
    10. Authorization: Basic dGVee5zdHF0OnbReexbe235lc3Rx
    11.  
    12. HTTP/1.x 200 OK
    13. Date: Wed, 21 Jun 2006 20:05:59 GMT
    14. Server: Apache/2.0.54 (Debian GNU/Linux) DAV/2 SVN/1.1.4 PHP/5.0.4-0.9sarge1 mod_perl/1.999.21 Perl/v5.8.4
    15. X-Powered-By: PHP/5.0.4-0.9sarge1
    16. Cache-Control: no-cache, must-revalidate
    17. Expires: Mon, 26 Jul 1997 05:00:00 GMT
    18. Vary: Accept-Encoding
    19. Content-Encoding: gzip
    20. Content-Length: 2639
    21. Keep-Alive: timeout=15, max=100
    22. Connection: Keep-Alive
    23. Content-Type: text/plain
    To copy to clipboard, switch view to plain text mode 

  14. #14
    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 get unparsed php file from WebDav! and same file firefox parse Ok.

    Quote Originally Posted by patrik08
    And now how configure etheral to read only tcp on port 80?
    Just enter "http" as filter.

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.