wget 中的 URL 後面是否允許新增正文資料?

wget 中的 URL 後面是否允許新增正文資料?

我剛剛意識到,由於我的錯誤,儘管如此wget手冊僅在末尾提到 URL,我可以指定 body-data 選項網址。這非常方便,但我想知道這是否是設計的行為。

$ 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

相關內容