write-out.d 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. c: Copyright (C) 1998 - 2022, Daniel Stenberg, <[email protected]>, et al.
  2. SPDX-License-Identifier: curl
  3. Long: write-out
  4. Short: w
  5. Arg: <format>
  6. Help: Use output FORMAT after completion
  7. Category: verbose
  8. Example: -w '%{http_code}\\n' $URL
  9. Added: 6.5
  10. See-also: verbose head
  11. ---
  12. Make curl display information on stdout after a completed transfer. The format
  13. is a string that may contain plain text mixed with any number of
  14. variables. The format can be specified as a literal "string", or you can have
  15. curl read the format from a file with "@filename" and to tell curl to read the
  16. format from stdin you write "@-".
  17. The variables present in the output format will be substituted by the value or
  18. text that curl thinks fit, as described below. All variables are specified as
  19. %{variable_name} and to output a normal % you just write them as %%. You can
  20. output a newline by using \\n, a carriage return with \\r and a tab space with
  21. \\t.
  22. The output will be written to standard output, but this can be switched to
  23. standard error by using %{stderr}.
  24. Output HTTP headers from the most recent request by using \fB%header{name}\fP
  25. where \fBname\fP is the case insensitive name of the header (without the
  26. trailing colon). The header contents are exactly as sent over the network,
  27. with leading and trailing whitespace trimmed. Added in curl 7.84.0.
  28. .B NOTE:
  29. The %-symbol is a special symbol in the win32-environment, where all
  30. occurrences of % must be doubled when using this option.
  31. The variables available are:
  32. .RS
  33. .TP 15
  34. .B content_type
  35. The Content-Type of the requested document, if there was any.
  36. .TP
  37. .B errormsg
  38. The error message. (Added in 7.75.0)
  39. .TP
  40. .B exitcode
  41. The numerical exitcode of the transfer. (Added in 7.75.0)
  42. .TP
  43. .B filename_effective
  44. The ultimate filename that curl writes out to. This is only meaningful if curl
  45. is told to write to a file with the --remote-name or --output
  46. option. It's most useful in combination with the --remote-header-name
  47. option. (Added in 7.26.0)
  48. .TP
  49. .B ftp_entry_path
  50. The initial path curl ended up in when logging on to the remote FTP
  51. server. (Added in 7.15.4)
  52. .TP
  53. .B header_json
  54. A JSON object with all HTTP response headers from the recent transfer. Values
  55. are provided as arrays, since in the case of multiple headers there can be
  56. multiple values.
  57. The header names provided in lowercase, listed in order of appearance over the
  58. wire. Except for duplicated headers. They are grouped on the first occurrence
  59. of that header, each value is presented in the JSON array.
  60. .TP
  61. .B http_code
  62. The numerical response code that was found in the last retrieved HTTP(S) or
  63. FTP(s) transfer.
  64. .TP
  65. .B http_connect
  66. The numerical code that was found in the last response (from a proxy) to a
  67. curl CONNECT request. (Added in 7.12.4)
  68. .TP
  69. .B http_version
  70. The http version that was effectively used. (Added in 7.50.0)
  71. .TP
  72. .B json
  73. A JSON object with all available keys.
  74. .TP
  75. .B local_ip
  76. The IP address of the local end of the most recently done connection - can be
  77. either IPv4 or IPv6. (Added in 7.29.0)
  78. .TP
  79. .B local_port
  80. The local port number of the most recently done connection. (Added in 7.29.0)
  81. .TP
  82. .B method
  83. The http method used in the most recent HTTP request. (Added in 7.72.0)
  84. .TP
  85. .B num_connects
  86. Number of new connects made in the recent transfer. (Added in 7.12.3)
  87. .TP
  88. .B num_headers
  89. The number of response headers in the most recent request (restarted at each
  90. redirect). Note that the status line IS NOT a header. (Added in 7.73.0)
  91. .TP
  92. .B num_redirects
  93. Number of redirects that were followed in the request. (Added in 7.12.3)
  94. .TP
  95. .B onerror
  96. The rest of the output is only shown if the transfer returned a non-zero error
  97. (Added in 7.75.0)
  98. .TP
  99. .B proxy_ssl_verify_result
  100. The result of the HTTPS proxy's SSL peer certificate verification that was
  101. requested. 0 means the verification was successful. (Added in 7.52.0)
  102. .TP
  103. .B redirect_url
  104. When an HTTP request was made without --location to follow redirects (or when
  105. --max-redirs is met), this variable will show the actual URL a redirect
  106. *would* have gone to. (Added in 7.18.2)
  107. .TP
  108. .B referer
  109. The Referer: header, if there was any. (Added in 7.76.0)
  110. .TP
  111. .B remote_ip
  112. The remote IP address of the most recently done connection - can be either
  113. IPv4 or IPv6. (Added in 7.29.0)
  114. .TP
  115. .B remote_port
  116. The remote port number of the most recently done connection. (Added in 7.29.0)
  117. .TP
  118. .B response_code
  119. The numerical response code that was found in the last transfer (formerly
  120. known as "http_code"). (Added in 7.18.2)
  121. .TP
  122. .B scheme
  123. The URL scheme (sometimes called protocol) that was effectively used. (Added in 7.52.0)
  124. .TP
  125. .B size_download
  126. The total amount of bytes that were downloaded. This is the size of the
  127. body/data that was transferred, excluding headers.
  128. .TP
  129. .B size_header
  130. The total amount of bytes of the downloaded headers.
  131. .TP
  132. .B size_request
  133. The total amount of bytes that were sent in the HTTP request.
  134. .TP
  135. .B size_upload
  136. The total amount of bytes that were uploaded. This is the size of the
  137. body/data that was transferred, excluding headers.
  138. .TP
  139. .B speed_download
  140. The average download speed that curl measured for the complete download. Bytes
  141. per second.
  142. .TP
  143. .B speed_upload
  144. The average upload speed that curl measured for the complete upload. Bytes per
  145. second.
  146. .TP
  147. .B ssl_verify_result
  148. The result of the SSL peer certificate verification that was requested. 0
  149. means the verification was successful. (Added in 7.19.0)
  150. .TP
  151. .B stderr
  152. From this point on, the --write-out output will be written to standard
  153. error. (Added in 7.63.0)
  154. .TP
  155. .B stdout
  156. From this point on, the --write-out output will be written to standard output.
  157. This is the default, but can be used to switch back after switching to stderr.
  158. (Added in 7.63.0)
  159. .TP
  160. .B time_appconnect
  161. The time, in seconds, it took from the start until the SSL/SSH/etc
  162. connect/handshake to the remote host was completed. (Added in 7.19.0)
  163. .TP
  164. .B time_connect
  165. The time, in seconds, it took from the start until the TCP connect to the
  166. remote host (or proxy) was completed.
  167. .TP
  168. .B time_namelookup
  169. The time, in seconds, it took from the start until the name resolving was
  170. completed.
  171. .TP
  172. .B time_pretransfer
  173. The time, in seconds, it took from the start until the file transfer was just
  174. about to begin. This includes all pre-transfer commands and negotiations that
  175. are specific to the particular protocol(s) involved.
  176. .TP
  177. .B time_redirect
  178. The time, in seconds, it took for all redirection steps including name lookup,
  179. connect, pretransfer and transfer before the final transaction was
  180. started. time_redirect shows the complete execution time for multiple
  181. redirections. (Added in 7.12.3)
  182. .TP
  183. .B time_starttransfer
  184. The time, in seconds, it took from the start until the first byte was just
  185. about to be transferred. This includes time_pretransfer and also the time the
  186. server needed to calculate the result.
  187. .TP
  188. .B time_total
  189. The total time, in seconds, that the full operation lasted.
  190. .TP
  191. .B url
  192. The URL that was fetched. (Added in 7.75.0)
  193. .TP
  194. .B urlnum
  195. The URL index number of this transfer, 0-indexed. De-globbed URLs share the
  196. same index number as the origin globbed URL. (Added in 7.75.0)
  197. .TP
  198. .B url_effective
  199. The URL that was fetched last. This is most meaningful if you have told curl
  200. to follow location: headers.
  201. .RE
  202. .IP
  203. If this option is used several times, the last one will be used.