writeout: add %time{}

Output the current UTC time using strftime format. %f is an extra curl
specific flag to output the microsecond fraction of the current second.

Verified by test 1981
This commit is contained in:
Daniel Stenberg 2025-07-31 16:41:36 +02:00
parent 30daac9f2f
commit 530e32777e
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
5 changed files with 331 additions and 3 deletions

View file

@ -238,7 +238,7 @@ test1933 test1934 test1935 test1936 test1937 test1938 test1939 test1940 \
test1941 test1942 test1943 test1944 test1945 test1946 test1947 test1948 \
test1955 test1956 test1957 test1958 test1959 test1960 test1964 \
test1970 test1971 test1972 test1973 test1974 test1975 test1976 test1977 \
test1978 test1979 test1980 \
test1978 test1979 test1980 test1981 \
\
test2000 test2001 test2002 test2003 test2004 test2005 \
\

62
tests/data/test1981 Normal file
View file

@ -0,0 +1,62 @@
<testcase>
<info>
<keywords>
HTTP
HTTP GET
</keywords>
</info>
#
# Server-side
<reply>
<data crlf="yes" nocheck="yes">
HTTP/1.1 200 OK
Date: Tue, 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>
</reply>
#
# Client-side
<client>
<server>
http
</server>
<name>
%time output with --write-out
</name>
<features>
Debug
</features>
<setenv>
CURL_TIME=1754037100
</setenv>
<command>
http://%HOSTIP:%HTTPPORT/%TESTNUMBER --write-out='Time: %time{%d/%b/%Y %H:%M:%S.%f %z}\n' -s -o %LOGDIR/dump
</command>
</client>
#
# Verify data after the test has been "shot"
<verify>
<protocol crlf="yes">
GET /%TESTNUMBER HTTP/1.1
Host: %HOSTIP:%HTTPPORT
User-Agent: curl/%VERSION
Accept: */*
</protocol>
<stdout mode="text">
Time: 01/Aug/2025 08:31:40.037100 +0000
</stdout>
</verify>
</testcase>