aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Frank <fabian@pagefault.de>2014-01-20 13:14:04 -0800
committerDaniel Stenberg <daniel@haxx.se>2014-01-20 22:57:55 +0100
commit852a018e78c4976e3cf07212e8022546edb2c120 (patch)
tree9f0533ac8df3d2cfb4bfaa7f9d023a478265d04c
parent82de54dd38938b647dd3bc14a0150e2a7d3a1b94 (diff)
SFTP: stat remote file also when CURLOPT_NOBODY is 1
Make it possible to call curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &filesize) and related functions on remote sftp:// files, without downloading them. Reported-by: Yingwei Liu Bug: http://curl.haxx.se/mail/lib-2014-01/0139.html
-rw-r--r--lib/ssh.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/ssh.c b/lib/ssh.c
index 9838c9579..80906d814 100644
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -1568,9 +1568,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
if(data->set.upload)
state(conn, SSH_SFTP_UPLOAD_INIT);
else {
- if(data->set.opt_no_body)
- state(conn, SSH_STOP);
- else if(sftp_scp->path[strlen(sftp_scp->path)-1] == '/')
+ if(sftp_scp->path[strlen(sftp_scp->path)-1] == '/')
state(conn, SSH_SFTP_READDIR_INIT);
else
state(conn, SSH_SFTP_DOWNLOAD_INIT);
@@ -1808,6 +1806,10 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
break;
case SSH_SFTP_READDIR_INIT:
+ Curl_pgrsSetDownloadSize(data, -1);
+ if(data->set.opt_no_body)
+ state(conn, SSH_STOP);
+
/*
* This is a directory that we are trying to get, so produce a directory
* listing
@@ -2065,6 +2067,7 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
*/
data->req.size = -1;
data->req.maxdownload = -1;
+ Curl_pgrsSetDownloadSize(data, -1);
}
else {
curl_off_t size = attrs.filesize;
@@ -2142,6 +2145,10 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
SFTP_SEEK(sshc->sftp_handle, data->state.resume_from);
}
}
+
+ if(data->set.opt_no_body)
+ state(conn, SSH_SFTP_CLOSE);
+
/* Setup the actual download */
if(data->req.size == 0) {
/* no data to transfer */