diff --git a/lib/file.c b/lib/file.c
index 3cfa0e7038..722b55e9d2 100644
--- a/lib/file.c
+++ b/lib/file.c
@@ -386,7 +386,6 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
*done = TRUE; /* unconditionally */
- Curl_initinfo(data);
Curl_pgrsStartNow(data);
if(data->set.upload)
@@ -413,21 +412,18 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
}
}
- /* If we have selected NOBODY and HEADER, it means that we only want file
- information. Which for FILE can't be much more than the file size and
- date. */
- if(data->set.opt_no_body && data->set.include_header && fstated) {
+ if(fstated) {
time_t filetime;
struct tm buffer;
const struct tm *tm = &buffer;
char header[80];
snprintf(header, sizeof(header),
"Content-Length: %" CURL_FORMAT_CURL_OFF_T "\r\n", expected_size);
- result = Curl_client_write(conn, CLIENTWRITE_BOTH, header, 0);
+ result = Curl_client_write(conn, CLIENTWRITE_HEADER, header, 0);
if(result)
return result;
- result = Curl_client_write(conn, CLIENTWRITE_BOTH,
+ result = Curl_client_write(conn, CLIENTWRITE_HEADER,
(char *)"Accept-ranges: bytes\r\n", 0);
if(result)
return result;
@@ -439,19 +435,22 @@ static CURLcode file_do(struct connectdata *conn, bool *done)
/* format: "Tue, 15 Nov 1994 12:45:26 GMT" */
snprintf(header, sizeof(header),
- "Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n",
+ "Last-Modified: %s, %02d %s %4d %02d:%02d:%02d GMT\r\n%s",
Curl_wkday[tm->tm_wday?tm->tm_wday-1:6],
tm->tm_mday,
Curl_month[tm->tm_mon],
tm->tm_year + 1900,
tm->tm_hour,
tm->tm_min,
- tm->tm_sec);
- result = Curl_client_write(conn, CLIENTWRITE_BOTH, header, 0);
- if(!result)
- /* set the file size to make it available post transfer */
- Curl_pgrsSetDownloadSize(data, expected_size);
- return result;
+ tm->tm_sec,
+ data->set.opt_no_body ? "": "\r\n");
+ result = Curl_client_write(conn, CLIENTWRITE_HEADER, header, 0);
+ if(result)
+ return result;
+ /* set the file size to make it available post transfer */
+ Curl_pgrsSetDownloadSize(data, expected_size);
+ if(data->set.opt_no_body)
+ return result;
}
/* Check whether file range has been specified */
diff --git a/lib/getinfo.c b/lib/getinfo.c
index 14b456274a..54c2c2f1cb 100644
--- a/lib/getinfo.c
+++ b/lib/getinfo.c
@@ -85,7 +85,6 @@ CURLcode Curl_initinfo(struct Curl_easy *data)
#ifdef USE_SSL
Curl_ssl_free_certinfo(data);
#endif
-
return CURLE_OK;
}
diff --git a/lib/url.c b/lib/url.c
index f152319e7a..cde51186c3 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -3745,6 +3745,7 @@ static CURLcode create_conn(struct Curl_easy *data,
/* this is supposed to be the connect function so we better at least check
that the file is present here! */
DEBUGASSERT(conn->handler->connect_it);
+ Curl_persistconninfo(conn);
result = conn->handler->connect_it(conn, &done);
/* Setup a "faked" transfer that'll do nothing */
diff --git a/src/tool_cb_hdr.c b/src/tool_cb_hdr.c
index 04bc7e17bb..f098822842 100644
--- a/src/tool_cb_hdr.c
+++ b/src/tool_cb_hdr.c
@@ -158,8 +158,9 @@ size_t tool_header_cb(char *ptr, size_t size, size_t nmemb, void *userdata)
}
if(hdrcbdata->config->show_headers &&
- (protocol & (CURLPROTO_HTTP|CURLPROTO_HTTPS|CURLPROTO_RTSP))) {
- /* bold headers only happen for HTTP(S) and RTSP */
+ (protocol &
+ (CURLPROTO_HTTP|CURLPROTO_HTTPS|CURLPROTO_RTSP|CURLPROTO_FILE))) {
+ /* bold headers only for selected protocols */
char *value = NULL;
if(!outs->stream && !tool_create_output_file(outs, FALSE))
diff --git a/tests/data/test1016 b/tests/data/test1016
index b404cacb61..4927f9eaa8 100644
--- a/tests/data/test1016
+++ b/tests/data/test1016
@@ -22,7 +22,7 @@ file
X-Y range on a file:// URL to stdout
-
+
-r 1-4 file://localhost/%PWD/log/test1016.txt
diff --git a/tests/data/test1017 b/tests/data/test1017
index 6fbc38ab2e..cfdd80f9e2 100644
--- a/tests/data/test1017
+++ b/tests/data/test1017
@@ -23,7 +23,7 @@ file
0-Y range on a file:// URL to stdout
-
+
-r 0-3 file://localhost/%PWD/log/test1017.txt
diff --git a/tests/data/test1018 b/tests/data/test1018
index 28a7027d9e..57487014fb 100644
--- a/tests/data/test1018
+++ b/tests/data/test1018
@@ -22,7 +22,7 @@ file
X-X range on a file:// URL to stdout
-
+
-r 4-4 file://localhost/%PWD/log/test1018.txt
diff --git a/tests/data/test1019 b/tests/data/test1019
index 4d9872a2d0..054e38d5d7 100644
--- a/tests/data/test1019
+++ b/tests/data/test1019
@@ -23,7 +23,7 @@ file
X- range on a file:// URL to stdout
-
+
-r 7- file://localhost/%PWD/log/test1019.txt
diff --git a/tests/data/test1020 b/tests/data/test1020
index 61032fb178..8e03a1758b 100644
--- a/tests/data/test1020
+++ b/tests/data/test1020
@@ -23,7 +23,7 @@ file
-Y range on a file:// URL to stdout
-
+
-r -9 file://localhost/%PWD/log/test1020.txt
diff --git a/tests/data/test1029 b/tests/data/test1029
index 2ffc7c64ae..c77209cad8 100644
--- a/tests/data/test1029
+++ b/tests/data/test1029
@@ -29,7 +29,7 @@ http
HTTP Location: and 'redirect_url' check
-
+
http://%HOSTIP:%HTTPPORT/we/want/our/1029 -w '%{redirect_url}\n'
diff --git a/tests/data/test1146 b/tests/data/test1146
index 43f33b7930..636748ee5c 100644
--- a/tests/data/test1146
+++ b/tests/data/test1146
@@ -24,7 +24,7 @@ file
--proto-default file
-
+
--proto-default file %PWD/log/test1146.txt
diff --git a/tests/data/test1220 b/tests/data/test1220
index 959abbf709..6752eb5804 100644
--- a/tests/data/test1220
+++ b/tests/data/test1220
@@ -20,7 +20,7 @@ file
file:// URLs with query string
-
+
file://localhost/%PWD/log/test1220.txt?a_query=foobar#afragment
diff --git a/tests/data/test200 b/tests/data/test200
index 8be1de0c74..c27f7c095d 100644
--- a/tests/data/test200
+++ b/tests/data/test200
@@ -23,7 +23,7 @@ file
basic file:// file
-
+
file://localhost/%PWD/log/test200.txt
diff --git a/tests/data/test2000 b/tests/data/test2000
index d3edb16e5a..db1ba13304 100644
--- a/tests/data/test2000
+++ b/tests/data/test2000
@@ -31,7 +31,7 @@ file
FTP RETR followed by FILE
-
+
ftp://%HOSTIP:%FTPPORT/2000 file://localhost/%PWD/log/test2000.txt
diff --git a/tests/data/test2001 b/tests/data/test2001
index 68c0df7841..88a258ebb8 100644
--- a/tests/data/test2001
+++ b/tests/data/test2001
@@ -48,7 +48,7 @@ file
HTTP GET followed by FTP RETR followed by FILE
-
+
http://%HOSTIP:%HTTPPORT/20010001 ftp://%HOSTIP:%FTPPORT/20010002 file://localhost/%PWD/log/test2001.txt
@@ -81,17 +81,6 @@ RETR 20010002
QUIT
-HTTP/1.1 200 OK
-Date: Thu, 09 Nov 2010 14:49:00 GMT
-Server: test-server/fake
-Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
-ETag: "21025-dc7-39462498"
-Accept-Ranges: bytes
-Content-Length: 6
-Connection: close
-Content-Type: text/html
-Funny-head: yesyes
-
-foo-
data
to
diff --git a/tests/data/test2002 b/tests/data/test2002
index db96bfea80..6dd2f9310a 100644
--- a/tests/data/test2002
+++ b/tests/data/test2002
@@ -57,7 +57,7 @@ tftp
HTTP GET followed by FTP RETR followed by FILE followed by TFTP RRQ
-
+
http://%HOSTIP:%HTTPPORT/20020001 ftp://%HOSTIP:%FTPPORT/20020002 file://localhost/%PWD/log/test2002.txt tftp://%HOSTIP:%TFTPPORT//20020003
@@ -96,17 +96,6 @@ filename: /20020003
QUIT
-HTTP/1.1 200 OK
-Date: Thu, 09 Nov 2010 14:49:00 GMT
-Server: test-server/fake
-Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
-ETag: "21025-dc7-39462498"
-Accept-Ranges: bytes
-Content-Length: 6
-Connection: close
-Content-Type: text/html
-Funny-head: yesyes
-
-foo-
data
to
diff --git a/tests/data/test2003 b/tests/data/test2003
index 59a743f857..09bee8e220 100644
--- a/tests/data/test2003
+++ b/tests/data/test2003
@@ -57,8 +57,8 @@ tftp
HTTP GET followed by FTP RETR followed by FILE followed by TFTP RRQ then again in reverse order
-
-http://%HOSTIP:%HTTPPORT/20030001 ftp://%HOSTIP:%FTPPORT/20030002 file://localhost/%PWD/log/test2003.txt tftp://%HOSTIP:%TFTPPORT//20030003 tftp://%HOSTIP:%TFTPPORT//20030003 file://localhost/%PWD/log/test2003.txt ftp://%HOSTIP:%FTPPORT/20030002 http://%HOSTIP:%HTTPPORT/20030001
+
+http://%HOSTIP:%HTTPPORT/20030001 ftp://%HOSTIP:%FTPPORT/20030002 file://localhost/%PWD/log/test2003.txt tftp://%HOSTIP:%TFTPPORT//20030003 tftp://%HOSTIP:%TFTPPORT//20030003 file://localhost/%PWD/log/test2003.txt ftp://%HOSTIP:%FTPPORT/20030002 http://%HOSTIP:%HTTPPORT/20030001
foo
@@ -109,17 +109,6 @@ Accept: */*
QUIT
-HTTP/1.1 200 OK
-Date: Thu, 09 Nov 2010 14:49:00 GMT
-Server: test-server/fake
-Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
-ETag: "21025-dc7-39462498"
-Accept-Ranges: bytes
-Content-Length: 6
-Connection: close
-Content-Type: text/html
-Funny-head: yesyes
-
-foo-
data
to
@@ -151,17 +140,6 @@ data
that FTP
works
so does it?
-HTTP/1.1 200 OK
-Date: Thu, 09 Nov 2010 14:49:00 GMT
-Server: test-server/fake
-Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
-ETag: "21025-dc7-39462498"
-Accept-Ranges: bytes
-Content-Length: 6
-Connection: close
-Content-Type: text/html
-Funny-head: yesyes
-
-foo-
diff --git a/tests/data/test2004 b/tests/data/test2004
index 4773f69032..b17890b0f6 100644
--- a/tests/data/test2004
+++ b/tests/data/test2004
@@ -29,7 +29,7 @@ sftp
TFTP RRQ followed by SFTP retrieval followed by FILE followed by SCP retrieval then again in reverse order
-
+
--key curl_client_key --pubkey curl_client_key.pub -u %USER: tftp://%HOSTIP:%TFTPPORT//2004 sftp://%HOSTIP:%SSHPORT%POSIX_PWD/log/test2004.txt file://localhost/%PWD/log/test2004.txt scp://%HOSTIP:%SSHPORT%POSIX_PWD/log/test2004.txt file://localhost/%PWD/log/test2004.txt sftp://%HOSTIP:%SSHPORT%POSIX_PWD/log/test2004.txt tftp://%HOSTIP:%TFTPPORT//2004 --insecure
diff --git a/tests/data/test2006 b/tests/data/test2006
index e25556fccd..3acbdaee2e 100644
--- a/tests/data/test2006
+++ b/tests/data/test2006
@@ -4,6 +4,7 @@
Metalink
HTTP
HTTP GET
+FILE
@@ -85,6 +86,10 @@ Accept: */*
Some data delivered from an HTTP resource
+Content-Length: 496
+Accept-ranges: bytes
+
+
HTTP/1.1 200 OK
Date: Thu, 21 Jun 2012 14:49:01 GMT
Server: test-server/fake
@@ -105,6 +110,9 @@ Metalink: fetching (log/download2006) from (http://%HOSTIP:%HTTPPORT/2006) OK
Metalink: validating (log/download2006)...
Metalink: validating (log/download2006) [sha-256] OK
+
+s/Last-Modified:.*//
+
$_ = '' if (($_ !~ /^Metalink: /) && ($_ !~ /error/i) && ($_ !~ /warn/i))
diff --git a/tests/data/test2007 b/tests/data/test2007
index cc4bd8c327..b169c49060 100644
--- a/tests/data/test2007
+++ b/tests/data/test2007
@@ -5,6 +5,7 @@ Metalink
HTTP
HTTP GET
-J
+FILE
@@ -85,7 +86,14 @@ Accept: */*
Something delivered from an HTTP resource
+
+s/Last-Modified:.*//
+
+Content-Length: 496
+Accept-ranges: bytes
+
+
HTTP/1.1 200 OK
Date: Thu, 21 Jun 2012 14:50:02 GMT
Server: test-server/fake
diff --git a/tests/data/test2008 b/tests/data/test2008
index 5843792607..012f221c47 100644
--- a/tests/data/test2008
+++ b/tests/data/test2008
@@ -4,6 +4,7 @@
Metalink
HTTP
HTTP GET
+FILE
@@ -77,7 +78,14 @@ Accept: */*
Some stuff delivered from an HTTP resource
+
+s/Last-Modified:.*//
+
+Content-Length: 496
+Accept-ranges: bytes
+
+
HTTP/1.1 200 OK
Date: Thu, 21 Jun 2012 15:23:48 GMT
Server: test-server/fake
diff --git a/tests/data/test2009 b/tests/data/test2009
index 84482ce890..b0e5c6c66e 100644
--- a/tests/data/test2009
+++ b/tests/data/test2009
@@ -5,6 +5,7 @@ Metalink
HTTP
HTTP GET
-J
+FILE
@@ -78,7 +79,14 @@ Accept: */*
Some contents delivered from an HTTP resource
+
+s/Last-Modified:.*//
+
+Content-Length: 496
+Accept-ranges: bytes
+
+
HTTP/1.1 200 OK
Date: Thu, 21 Jun 2012 16:27:17 GMT
Server: test-server/fake
diff --git a/tests/data/test2010 b/tests/data/test2010
index 91a83f4dc8..33bb309ebf 100644
--- a/tests/data/test2010
+++ b/tests/data/test2010
@@ -4,6 +4,7 @@
Metalink
HTTP
HTTP GET
+FILE
@@ -77,7 +78,14 @@ Accept: */*
Contents delivered from an HTTP resource
+
+s/Last-Modified:.*//
+
+Content-Length: 496
+Accept-ranges: bytes
+
+
HTTP/1.1 200 OK
Date: Thu, 21 Jun 2012 17:37:27 GMT
Server: test-server/fake
diff --git a/tests/data/test202 b/tests/data/test202
index f863ec507c..0b324b1d80 100644
--- a/tests/data/test202
+++ b/tests/data/test202
@@ -19,7 +19,7 @@ file
two file:// URLs to stdout
-
+
file://localhost/%PWD/log/test202.txt FILE://localhost/%PWD/log/test202.txt
diff --git a/tests/data/test203 b/tests/data/test203
index 366cc2cd09..393842656f 100644
--- a/tests/data/test203
+++ b/tests/data/test203
@@ -24,7 +24,7 @@ file
file:/path URL with a single slash
-
+
file:%PWD/log/test203.txt
diff --git a/tests/data/test204 b/tests/data/test204
index 9cc7b01541..0ed94512f9 100644
--- a/tests/data/test204
+++ b/tests/data/test204
@@ -15,7 +15,7 @@ file
"upload" with file://
-
+
file://localhost/%PWD/log/result204.txt -T log/upload204.txt
diff --git a/tests/data/test205 b/tests/data/test205
index 4af93f6423..f83c531578 100644
--- a/tests/data/test205
+++ b/tests/data/test205
@@ -16,7 +16,7 @@ file
"upload" with file://
-
+
file://localhost/%PWD/log/nonexisting/result205.txt -T log/upload205.txt
diff --git a/tests/data/test2070 b/tests/data/test2070
index bc3898ab31..655cd8a39f 100644
--- a/tests/data/test2070
+++ b/tests/data/test2070
@@ -23,7 +23,7 @@ file
basic file:// file with no authority
-
+
file:%PWD/log/test2070.txt
diff --git a/tests/data/test2071 b/tests/data/test2071
index 997dfffeb0..eddfa4df7b 100644
--- a/tests/data/test2071
+++ b/tests/data/test2071
@@ -23,7 +23,7 @@ file
basic file:// file with "127.0.0.1" hostname
-
+
file://127.0.0.1/%PWD/log/test2070.txt
diff --git a/tests/data/test2072 b/tests/data/test2072
index cd26f22bd6..1bab158887 100644
--- a/tests/data/test2072
+++ b/tests/data/test2072
@@ -23,7 +23,7 @@ file
file:// with unix path resolution behavior for the case of extra slashes
-
+
file:////%PWD/log/test2072.txt
diff --git a/tests/data/test210 b/tests/data/test210
index e904567544..c6fb703093 100644
--- a/tests/data/test210
+++ b/tests/data/test210
@@ -22,7 +22,7 @@ ftp
Get two FTP files from the same remote dir: no second CWD
-
+
ftp://%HOSTIP:%FTPPORT/a/path/210 ftp://%HOSTIP:%FTPPORT/a/path/210
diff --git a/tests/data/test231 b/tests/data/test231
index 6994957c12..3d4bc77301 100644
--- a/tests/data/test231
+++ b/tests/data/test231
@@ -22,7 +22,7 @@ file
file:// with resume
-
+
file://localhost/%PWD/log/test231.txt -C 10
diff --git a/tests/data/test288 b/tests/data/test288
index ff4db6a472..9f8f6e1219 100644
--- a/tests/data/test288
+++ b/tests/data/test288
@@ -30,7 +30,7 @@ file:// with (unsupported) proxy, authentication and range
all_proxy=http://fake:user@%HOSTIP:%HTTPPORT/
-
+
file://localhost/%PWD/log/test288.txt