Re: lftp 3.1 : problem with webdav MOVE

"Alexander V. Lukyanov" <[email protected]>
Newsgroups gmane.network.lftp.devel
Message-ID <[email protected]>
On Tue, Mar 01, 2005 at 10:10:39PM +0100, Clement Hermann wrote:
> However, I've got a small problem with MOVE requests, it complains about
> it beeing bad formated :

Does this patch fix the problem?

> the Destination could even be another server. This is not handled by

It could only be done as quote command extension. Same for COPY request.

--
   Alexander.
diff (text/plain, 2.5 KB)
Index: FileAccess.cc
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/FileAccess.cc,v
retrieving revision 1.117
diff -u -p -r1.117 FileAccess.cc
--- FileAccess.cc	10 Feb 2005 13:37:16 -0000	1.117
+++ FileAccess.cc	2 Mar 2005 11:01:13 -0000
@@ -402,7 +402,8 @@ const char *FileAccess::GetFileURL(const
    {
       if(!f || (f[0]!='/' && f[0]!='~'))
 	 f=dir_file(cwd?cwd:"~",f);
-      u.path=(char*)f;
+      u.path=alloca_strdup(f);
+      OptimizePath(u.path,/*strip_trailing_slash*/false);
    }
 
    xfree(url);
@@ -571,7 +572,7 @@ int FileAccess::device_prefix_len(const 
    return 0;
 }
 
-void FileAccess::OptimizePath(char *path)
+void FileAccess::OptimizePath(char *path,bool strip_trailing_slash)
 {
    int	 prefix_size=0;
 
@@ -614,7 +615,7 @@ void FileAccess::OptimizePath(char *path
       if(in[0]=='/')
       {
 	 // double slash or a slash on the end
-	 if(in[1]=='/' || in[1]=='\0')
+	 if(in[1]=='/' || (strip_trailing_slash && in[1]=='\0'))
 	 {
 	    in++;
 	    continue;
Index: FileAccess.h
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/FileAccess.h,v
retrieving revision 1.82
diff -u -p -r1.82 FileAccess.h
--- FileAccess.h	4 Feb 2005 15:25:51 -0000	1.82
+++ FileAccess.h	2 Mar 2005 11:00:15 -0000
@@ -221,7 +221,7 @@ public:
    virtual void	Rename(const char *rfile,const char *to);
    virtual void Mkdir(const char *rfile,bool allpath=false);
    virtual void Chdir(const char *dir,bool verify=true);
-   void OptimizePath(char *path);
+   void OptimizePath(char *path,bool strip_trailing_slash=true);
    void SetCwd(const char *dir) { xfree(cwd); cwd=xstrdup(dir); }
    void Remove(const char *rfile)    { Open(rfile,REMOVE); }
    void RemoveDir(const char *dir)  { Open(dir,REMOVE_DIR); }
Index: Http.cc
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/Http.cc,v
retrieving revision 1.187
diff -u -p -r1.187 Http.cc
--- Http.cc	25 Feb 2005 12:47:41 -0000	1.187
+++ Http.cc	2 Mar 2005 06:54:40 -0000
@@ -609,11 +609,7 @@ void Http::SendRequest(const char *conne
    case RENAME:
       {
 	 SendMethod("MOVE",efile);
-	 char *efile1=string_alloca(strlen(file1)*3+1);
-	 url::encode_string(file1,efile1,URL_PATH_UNSAFE);
-	 char *pfile1=string_alloca(strlen(ecwd)+1+strlen(efile1)+1+6+1);
-	 DirFile(pfile1,ecwd,efile1);
-	 Send("Destination: %s\r\n",pfile1);
+	 Send("Destination: %s\r\n",GetFileURL(file1));
       }
    }
    SendAuth();
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.