我刚刚意识到,由于我的失误,wget 手册仅在末尾提及 URL,我可以指定 body-data 选项后URL。这非常方便,但我想知道这是否是设计的行为。
$ wget --method=PUT -O - http://httpbin.org/put --body-data='abcdefg'
--2019-03-27 10:52:30-- http://httpbin.org/put
Resolving httpbin.org (httpbin.org)... 3.85.154.144, 52.71.234.219
Connecting to httpbin.org (httpbin.org)|3.85.154.144|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 415 [application/json]
Saving to: ‘STDOUT’
- 0%[ ] 0 --.-KB/s {
"args": {},
"data": "",
"files": {},
"form": {
"abcdefg": ""
},
"headers": {
"Accept": "*/*",
"Accept-Encoding": "identity",
"Content-Length": "7",
"Content-Type": "application/x-www-form-urlencoded",
"Host": "httpbin.org",
"User-Agent": "Wget/1.19.1 (cygwin)"
},
"json": null,
"origin": "50.203.83.51, 50.203.83.51",
"url": "https://httpbin.org/put"
}
- 100%[==============================================>] 415 --.-KB/s in 0s
2019-03-27 10:52:30 (4.53 MB/s) - written to stdout [415/415]
答案1
是的,这是受支持的行为。对于 Wget 命令行,您可以将 URL 放在任何位置。
编辑:来自info wget
,第 2.2 节,选项语法:
由于 Wget 使用 GNU getopt 来处理命令行参数,因此每个选项都有长格式和短格式。长选项更方便记忆,但输入起来费时。您可以自由混合不同的选项样式,或在命令行参数后指定选项。因此您可以这样写:
wget -r --tries=10 http://fly.srk.fer.hr/ -o log