Bug 60904

Summary: HTTP KIO slave's stat always returns that a file exists
Product: [Frameworks and Libraries] kio Reporter: Leif Huhn <lb.kdebugzilla>
Component: httpAssignee: Unassigned bugs mailing-list <unassigned-bugs>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:

Description Leif Huhn 2003-07-08 06:54:21 UTC
Version:            (using KDE KDE 3.1.2)

The http KIO slave doesn't even bother determining if a file exists in stat if not using webdav.

Ideally it should check.

If it doesn't check, then it should at least do the same thing the FTP KIO slave does when the server is braindamaged.  The FTP KIO slave does:

QString statSide = metaData(QString::fromLatin1("statSide"));
if ( statSide == "source" )
{
    kdDebug(7102) << "Not found, but assuming found, because some servers don't allow listing" << endl;
    // MS Server is incapable of handling "list <blah>" in a case insensitive way
    // But "retr <blah>" works. So lie in stat(), to get going...
    //
    // There's also the case of ftp://ftp2.3ddownloads.com/90380/linuxgames/loki/patches/ut/ut-patch-436.run
    // where listing permissions are denied, but downloading is still possible.
    shortStatAnswer( filename, false /*file, not dir*/ );
}
else
{
    error( ERR_DOES_NOT_EXIST, path );
}

For my application returning that a file *doesn't* exist is a more sensible default.
Comment 1 Waldo Bastian 2003-07-08 11:47:41 UTC
Subject: kdelibs/kioslave/http

CVS commit by waba: 

CCMAIL: 60904-done@bugs.kde.org
* Bounce referrer back to application
* Let stat() return what the application wants to hear. (BR60904)


  M +11 -0     http.cc   1.583


--- kdelibs/kioslave/http/http.cc  #1.582:1.583
@@ -322,4 +322,6 @@ void HTTPProtocol::resetSessionSettings(
   m_remoteRespTimeout = responseTimeout();
 
+  // Bounce back the actual referrer sent
+  setMetaData("referrer", m_request.referrer);
 
   // Set the SSL meta-data here...
@@ -523,4 +525,13 @@ void HTTPProtocol::stat(const KURL& url)
   if ( m_protocol != "webdav" && m_protocol != "webdavs" )
   {
+    QString statSide = metaData(QString::fromLatin1("statSide"));
+    if ( statSide != "source" )
+    {
+      // When uploading we assume the file doesn't exit
+      error( ERR_DOES_NOT_EXIST, url.prettyURL() );
+      return;
+    }
+
+    // When downloading we assume it exists
     UDSEntry entry;
     UDSAtom atom;