2023-01-02 20:51:48 +08:00
|
|
|
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
2022-06-14 06:12:03 +08:00
|
|
|
SPDX-License-Identifier: curl
|
2016-11-28 08:01:13 +08:00
|
|
|
Long: write-out
|
|
|
|
Short: w
|
|
|
|
Arg: <format>
|
|
|
|
Help: Use output FORMAT after completion
|
2020-07-13 20:15:04 +08:00
|
|
|
Category: verbose
|
2021-08-31 22:37:14 +08:00
|
|
|
Example: -w '%{http_code}\\n' $URL
|
2021-09-28 17:50:07 +08:00
|
|
|
Added: 6.5
|
2021-11-15 22:58:20 +08:00
|
|
|
See-also: verbose head
|
2022-10-18 16:39:43 +08:00
|
|
|
Multi: single
|
2016-11-28 08:01:13 +08:00
|
|
|
---
|
|
|
|
Make curl display information on stdout after a completed transfer. The format
|
|
|
|
is a string that may contain plain text mixed with any number of
|
|
|
|
variables. The format can be specified as a literal "string", or you can have
|
|
|
|
curl read the format from a file with "@filename" and to tell curl to read the
|
|
|
|
format from stdin you write "@-".
|
|
|
|
|
|
|
|
The variables present in the output format will be substituted by the value or
|
|
|
|
text that curl thinks fit, as described below. All variables are specified as
|
|
|
|
%{variable_name} and to output a normal % you just write them as %%. You can
|
|
|
|
output a newline by using \\n, a carriage return with \\r and a tab space with
|
|
|
|
\\t.
|
|
|
|
|
2018-10-09 05:54:01 +08:00
|
|
|
The output will be written to standard output, but this can be switched to
|
|
|
|
standard error by using %{stderr}.
|
|
|
|
|
2022-05-30 20:13:48 +08:00
|
|
|
Output HTTP headers from the most recent request by using \fB%header{name}\fP
|
|
|
|
where \fBname\fP is the case insensitive name of the header (without the
|
|
|
|
trailing colon). The header contents are exactly as sent over the network,
|
|
|
|
with leading and trailing whitespace trimmed. Added in curl 7.84.0.
|
2022-03-17 23:32:45 +08:00
|
|
|
|
2016-11-28 08:01:13 +08:00
|
|
|
.B NOTE:
|
2023-01-23 16:44:16 +08:00
|
|
|
In Windows the %-symbol is a special symbol used to expand environment
|
|
|
|
variables. In batch files all occurrences of % must be doubled when using this
|
|
|
|
option to properly escape. If this option is used at the command prompt then
|
|
|
|
the % cannot be escaped and unintended expansion is possible.
|
2016-11-28 08:01:13 +08:00
|
|
|
|
|
|
|
The variables available are:
|
|
|
|
.RS
|
|
|
|
.TP 15
|
2022-12-27 19:00:12 +08:00
|
|
|
.B certs
|
|
|
|
Output the certificate chain with details. Supported only by the OpenSSL,
|
2023-04-06 17:01:14 +08:00
|
|
|
GnuTLS, Schannel, NSS, GSKit and Secure Transport backends. (Added in 7.88.0)
|
2022-12-27 19:00:12 +08:00
|
|
|
.TP
|
2016-11-28 08:01:13 +08:00
|
|
|
.B content_type
|
|
|
|
The Content-Type of the requested document, if there was any.
|
|
|
|
.TP
|
2020-12-14 17:09:51 +08:00
|
|
|
.B errormsg
|
|
|
|
The error message. (Added in 7.75.0)
|
|
|
|
.TP
|
|
|
|
.B exitcode
|
2021-01-29 07:56:50 +08:00
|
|
|
The numerical exitcode of the transfer. (Added in 7.75.0)
|
2020-12-14 17:09:51 +08:00
|
|
|
.TP
|
2016-11-28 08:01:13 +08:00
|
|
|
.B filename_effective
|
|
|
|
The ultimate filename that curl writes out to. This is only meaningful if curl
|
2016-12-18 06:56:50 +08:00
|
|
|
is told to write to a file with the --remote-name or --output
|
|
|
|
option. It's most useful in combination with the --remote-header-name
|
2016-11-28 08:01:13 +08:00
|
|
|
option. (Added in 7.26.0)
|
|
|
|
.TP
|
|
|
|
.B ftp_entry_path
|
|
|
|
The initial path curl ended up in when logging on to the remote FTP
|
|
|
|
server. (Added in 7.15.4)
|
|
|
|
.TP
|
2022-03-18 00:55:06 +08:00
|
|
|
.B header_json
|
2022-03-18 06:11:22 +08:00
|
|
|
A JSON object with all HTTP response headers from the recent transfer. Values
|
|
|
|
are provided as arrays, since in the case of multiple headers there can be
|
2023-02-02 09:27:23 +08:00
|
|
|
multiple values. (Added in 7.83.0)
|
2022-03-18 06:11:22 +08:00
|
|
|
|
2022-03-25 18:24:27 +08:00
|
|
|
The header names provided in lowercase, listed in order of appearance over the
|
2022-03-30 16:49:05 +08:00
|
|
|
wire. Except for duplicated headers. They are grouped on the first occurrence
|
2022-03-25 18:24:27 +08:00
|
|
|
of that header, each value is presented in the JSON array.
|
2022-03-18 00:55:06 +08:00
|
|
|
.TP
|
2016-11-28 08:01:13 +08:00
|
|
|
.B http_code
|
|
|
|
The numerical response code that was found in the last retrieved HTTP(S) or
|
2021-09-28 16:30:59 +08:00
|
|
|
FTP(s) transfer.
|
2016-11-28 08:01:13 +08:00
|
|
|
.TP
|
|
|
|
.B http_connect
|
|
|
|
The numerical code that was found in the last response (from a proxy) to a
|
|
|
|
curl CONNECT request. (Added in 7.12.4)
|
|
|
|
.TP
|
|
|
|
.B http_version
|
|
|
|
The http version that was effectively used. (Added in 7.50.0)
|
|
|
|
.TP
|
2020-02-02 01:55:24 +08:00
|
|
|
.B json
|
|
|
|
A JSON object with all available keys.
|
|
|
|
.TP
|
2016-11-28 08:01:13 +08:00
|
|
|
.B local_ip
|
|
|
|
The IP address of the local end of the most recently done connection - can be
|
2021-07-16 14:21:49 +08:00
|
|
|
either IPv4 or IPv6. (Added in 7.29.0)
|
2016-11-28 08:01:13 +08:00
|
|
|
.TP
|
|
|
|
.B local_port
|
2021-07-16 14:21:49 +08:00
|
|
|
The local port number of the most recently done connection. (Added in 7.29.0)
|
2016-11-28 08:01:13 +08:00
|
|
|
.TP
|
2020-07-13 15:58:29 +08:00
|
|
|
.B method
|
2021-07-16 14:21:49 +08:00
|
|
|
The http method used in the most recent HTTP request. (Added in 7.72.0)
|
2020-07-13 15:58:29 +08:00
|
|
|
.TP
|
2022-12-27 19:00:12 +08:00
|
|
|
.B num_certs
|
|
|
|
Number of server certificates received in the TLS handshake. Supported only by
|
2023-04-06 17:01:14 +08:00
|
|
|
the OpenSSL, GnuTLS, Schannel, NSS, GSKit and Secure Transport backends. (Added
|
2022-12-27 19:00:12 +08:00
|
|
|
in 7.88.0)
|
|
|
|
.TP
|
2016-11-28 08:01:13 +08:00
|
|
|
.B num_connects
|
|
|
|
Number of new connects made in the recent transfer. (Added in 7.12.3)
|
|
|
|
.TP
|
2020-09-09 23:05:49 +08:00
|
|
|
.B num_headers
|
|
|
|
The number of response headers in the most recent request (restarted at each
|
2022-01-31 14:04:19 +08:00
|
|
|
redirect). Note that the status line IS NOT a header. (Added in 7.73.0)
|
2020-09-09 23:05:49 +08:00
|
|
|
.TP
|
2016-11-28 08:01:13 +08:00
|
|
|
.B num_redirects
|
|
|
|
Number of redirects that were followed in the request. (Added in 7.12.3)
|
|
|
|
.TP
|
2020-12-14 17:09:51 +08:00
|
|
|
.B onerror
|
2023-04-06 17:01:14 +08:00
|
|
|
The rest of the output is only shown if the transfer returned a non-zero error.
|
2020-12-14 17:09:51 +08:00
|
|
|
(Added in 7.75.0)
|
|
|
|
.TP
|
2017-02-06 16:13:42 +08:00
|
|
|
.B proxy_ssl_verify_result
|
|
|
|
The result of the HTTPS proxy's SSL peer certificate verification that was
|
|
|
|
requested. 0 means the verification was successful. (Added in 7.52.0)
|
|
|
|
.TP
|
2016-11-28 08:01:13 +08:00
|
|
|
.B redirect_url
|
2017-05-23 16:32:18 +08:00
|
|
|
When an HTTP request was made without --location to follow redirects (or when
|
2021-05-26 10:55:18 +08:00
|
|
|
--max-redirs is met), this variable will show the actual URL a redirect
|
2021-03-22 23:50:57 +08:00
|
|
|
*would* have gone to. (Added in 7.18.2)
|
2016-11-28 08:01:13 +08:00
|
|
|
.TP
|
2021-02-19 21:57:19 +08:00
|
|
|
.B referer
|
|
|
|
The Referer: header, if there was any. (Added in 7.76.0)
|
|
|
|
.TP
|
2016-11-28 08:01:13 +08:00
|
|
|
.B remote_ip
|
|
|
|
The remote IP address of the most recently done connection - can be either
|
2021-07-16 14:21:49 +08:00
|
|
|
IPv4 or IPv6. (Added in 7.29.0)
|
2016-11-28 08:01:13 +08:00
|
|
|
.TP
|
|
|
|
.B remote_port
|
2021-07-16 14:21:49 +08:00
|
|
|
The remote port number of the most recently done connection. (Added in 7.29.0)
|
2016-11-28 08:01:13 +08:00
|
|
|
.TP
|
2020-05-11 23:47:01 +08:00
|
|
|
.B response_code
|
|
|
|
The numerical response code that was found in the last transfer (formerly
|
|
|
|
known as "http_code"). (Added in 7.18.2)
|
|
|
|
.TP
|
2016-11-28 08:01:13 +08:00
|
|
|
.B scheme
|
2021-07-16 14:21:49 +08:00
|
|
|
The URL scheme (sometimes called protocol) that was effectively used. (Added in 7.52.0)
|
2016-11-28 08:01:13 +08:00
|
|
|
.TP
|
|
|
|
.B size_download
|
2021-09-12 04:59:38 +08:00
|
|
|
The total amount of bytes that were downloaded. This is the size of the
|
2021-11-02 02:14:24 +08:00
|
|
|
body/data that was transferred, excluding headers.
|
2016-11-28 08:01:13 +08:00
|
|
|
.TP
|
|
|
|
.B size_header
|
|
|
|
The total amount of bytes of the downloaded headers.
|
|
|
|
.TP
|
|
|
|
.B size_request
|
|
|
|
The total amount of bytes that were sent in the HTTP request.
|
|
|
|
.TP
|
|
|
|
.B size_upload
|
2021-09-12 04:59:38 +08:00
|
|
|
The total amount of bytes that were uploaded. This is the size of the
|
2021-11-02 02:14:24 +08:00
|
|
|
body/data that was transferred, excluding headers.
|
2016-11-28 08:01:13 +08:00
|
|
|
.TP
|
|
|
|
.B speed_download
|
|
|
|
The average download speed that curl measured for the complete download. Bytes
|
|
|
|
per second.
|
|
|
|
.TP
|
|
|
|
.B speed_upload
|
|
|
|
The average upload speed that curl measured for the complete upload. Bytes per
|
|
|
|
second.
|
|
|
|
.TP
|
|
|
|
.B ssl_verify_result
|
|
|
|
The result of the SSL peer certificate verification that was requested. 0
|
|
|
|
means the verification was successful. (Added in 7.19.0)
|
|
|
|
.TP
|
2018-10-09 05:54:01 +08:00
|
|
|
.B stderr
|
|
|
|
From this point on, the --write-out output will be written to standard
|
|
|
|
error. (Added in 7.63.0)
|
|
|
|
.TP
|
|
|
|
.B stdout
|
|
|
|
From this point on, the --write-out output will be written to standard output.
|
|
|
|
This is the default, but can be used to switch back after switching to stderr.
|
|
|
|
(Added in 7.63.0)
|
|
|
|
.TP
|
2016-11-28 08:01:13 +08:00
|
|
|
.B time_appconnect
|
|
|
|
The time, in seconds, it took from the start until the SSL/SSH/etc
|
|
|
|
connect/handshake to the remote host was completed. (Added in 7.19.0)
|
|
|
|
.TP
|
|
|
|
.B time_connect
|
|
|
|
The time, in seconds, it took from the start until the TCP connect to the
|
|
|
|
remote host (or proxy) was completed.
|
|
|
|
.TP
|
|
|
|
.B time_namelookup
|
|
|
|
The time, in seconds, it took from the start until the name resolving was
|
|
|
|
completed.
|
|
|
|
.TP
|
|
|
|
.B time_pretransfer
|
|
|
|
The time, in seconds, it took from the start until the file transfer was just
|
|
|
|
about to begin. This includes all pre-transfer commands and negotiations that
|
|
|
|
are specific to the particular protocol(s) involved.
|
|
|
|
.TP
|
|
|
|
.B time_redirect
|
2017-04-04 07:04:03 +08:00
|
|
|
The time, in seconds, it took for all redirection steps including name lookup,
|
2016-11-28 08:01:13 +08:00
|
|
|
connect, pretransfer and transfer before the final transaction was
|
|
|
|
started. time_redirect shows the complete execution time for multiple
|
|
|
|
redirections. (Added in 7.12.3)
|
|
|
|
.TP
|
|
|
|
.B time_starttransfer
|
|
|
|
The time, in seconds, it took from the start until the first byte was just
|
|
|
|
about to be transferred. This includes time_pretransfer and also the time the
|
|
|
|
server needed to calculate the result.
|
|
|
|
.TP
|
|
|
|
.B time_total
|
2017-01-13 23:23:16 +08:00
|
|
|
The total time, in seconds, that the full operation lasted.
|
2016-11-28 08:01:13 +08:00
|
|
|
.TP
|
2020-12-14 17:09:51 +08:00
|
|
|
.B url
|
|
|
|
The URL that was fetched. (Added in 7.75.0)
|
|
|
|
.TP
|
tool_writeout: add URL component variables
Output specific components from the used URL. The following variables
are added for this purpose:
url.scheme, url.user, url.password, url.options, url.host, url.port,
url.path, url.query, url.fragment, url.zoneid
Add the following for outputting parts of the "effective URL":
urle.scheme, urle.user, urle.password, urle.options, urle.host, urle.port,
urle.path, urle.query, urle.fragment, urle.zoneid
Added test 423 and 424 to verify.
Closes #10853
2023-04-04 20:42:44 +08:00
|
|
|
.B url.scheme
|
|
|
|
The scheme part of the URL that was fetched. (Added in 8.1.0)
|
|
|
|
.TP
|
|
|
|
.B url.user
|
|
|
|
The user part of the URL that was fetched. (Added in 8.1.0)
|
|
|
|
.TP
|
|
|
|
.B url.password
|
|
|
|
The password part of the URL that was fetched. (Added in 8.1.0)
|
|
|
|
.TP
|
|
|
|
.B url.options
|
|
|
|
The options part of the URL that was fetched. (Added in 8.1.0)
|
|
|
|
.TP
|
|
|
|
.B url.host
|
|
|
|
The host part of the URL that was fetched. (Added in 8.1.0)
|
|
|
|
.TP
|
|
|
|
.B url.port
|
|
|
|
The port number of the URL that was fetched. If no port number was specified,
|
|
|
|
but the URL scheme is known, that scheme's default port number is
|
|
|
|
shown. (Added in 8.1.0)
|
|
|
|
.TP
|
|
|
|
.B url.path
|
|
|
|
The path part of the URL that was fetched. (Added in 8.1.0)
|
|
|
|
.TP
|
|
|
|
.B url.query
|
|
|
|
The query part of the URL that was fetched. (Added in 8.1.0)
|
|
|
|
.TP
|
|
|
|
.B url.fragment
|
|
|
|
The fragment part of the URL that was fetched. (Added in 8.1.0)
|
|
|
|
.TP
|
|
|
|
.B url.zoneid
|
|
|
|
The zoneid part of the URL that was fetched. (Added in 8.1.0)
|
|
|
|
.TP
|
|
|
|
.B urle.scheme
|
|
|
|
The scheme part of the effective (last) URL that was fetched. (Added in 8.1.0)
|
|
|
|
.TP
|
|
|
|
.B urle.user
|
|
|
|
The user part of the effective (last) URL that was fetched. (Added in 8.1.0)
|
|
|
|
.TP
|
|
|
|
.B urle.password
|
|
|
|
The password part of the effective (last) URL that was fetched. (Added in 8.1.0)
|
|
|
|
.TP
|
|
|
|
.B urle.options
|
|
|
|
The options part of the effective (last) URL that was fetched. (Added in 8.1.0)
|
|
|
|
.TP
|
|
|
|
.B urle.host
|
|
|
|
The host part of the effective (last) URL that was fetched. (Added in 8.1.0)
|
|
|
|
.TP
|
|
|
|
.B urle.port
|
|
|
|
The port number of the effective (last) URL that was fetched. If no port
|
|
|
|
number was specified, but the URL scheme is known, that scheme's default port
|
|
|
|
number is shown. (Added in 8.1.0)
|
|
|
|
.TP
|
|
|
|
.B urle.path
|
|
|
|
The path part of the effective (last) URL that was fetched. (Added in 8.1.0)
|
|
|
|
.TP
|
|
|
|
.B urle.query
|
|
|
|
The query part of the effective (last) URL that was fetched. (Added in 8.1.0)
|
|
|
|
.TP
|
|
|
|
.B urle.fragment
|
|
|
|
The fragment part of the effective (last) URL that was fetched. (Added in 8.1.0)
|
|
|
|
.TP
|
|
|
|
.B urle.zoneid
|
|
|
|
The zoneid part of the effective (last) URL that was fetched. (Added in 8.1.0)
|
|
|
|
.TP
|
2020-12-14 17:09:51 +08:00
|
|
|
.B urlnum
|
2021-07-09 12:55:52 +08:00
|
|
|
The URL index number of this transfer, 0-indexed. De-globbed URLs share the
|
|
|
|
same index number as the origin globbed URL. (Added in 7.75.0)
|
2020-12-14 17:09:51 +08:00
|
|
|
.TP
|
2016-11-28 08:01:13 +08:00
|
|
|
.B url_effective
|
2021-10-31 23:34:44 +08:00
|
|
|
The URL that was fetched last. This is most meaningful if you have told curl
|
2016-11-28 08:01:13 +08:00
|
|
|
to follow location: headers.
|
|
|
|
.RE
|
|
|
|
.IP
|