「CURL」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(序文を修正)
(→‎See also: 訳出)
40行目: 40行目:
 
$ curl -d ''<nowiki>'json body'</nowiki>'' -H 'Content-Type: application/json' ''URL''
 
$ curl -d ''<nowiki>'json body'</nowiki>'' -H 'Content-Type: application/json' ''URL''
   
== See also ==
+
== 参照 ==
   
* [[Wikipedia:cURL]]
+
* [[Wikipedia:ja:cURL]]
* [https://ec.haxx.se/ Everything curl] - Extensive guide to using cURL
+
* [https://ec.haxx.se/ Everything curl] - cURL の使用に関する広範なガイド
 
* {{man|1|curl}}
 
* {{man|1|curl}}

2021年8月9日 (月) 10:16時点における版

cURL は URL を使ってデータを転送するためのコマンドラインツールおよびライブラリです。このコマンドは、HTTP、HTTPS、FTPSCP や SFTP などさまざまなプロトコルをサポートしています。また、スクリプトのように、ユーザーの操作なしで動作するように設計されています。

インストール

curl パッケージをインストールします。

使用方法

ダウンロード

cURL の一般的な使用例は、指定したファイルにリソースをダウンロードすることです。

$ curl -o file name URL

URL にファイル名が含まれている場合は、リソースをその名前のファイルに直接保存できます。

$ curl -O URL

同様に、-J を使用すると、ファイルの名前を決めるためのヒントを HTTP サーバー (Content-Disposition ヘッダー) から受け取ることができます。-O と組み合わせると、HTTP サーバーが応答でファイル名のヒントを返さなかった場合は、curl は URL で指定されたファイル名を使用します。

また、出力オプションを省略して、リソースを標準出力に出力することもできます。

$ curl URL

HTTP POST

You can use cURL to make HTTP POST requests:

$ curl -d 'request body' URL

If the request body cannot fit on the command line, cURL can read it from a file:

$ curl -d @file name URL

Sometimes, you may need to specify a custom value for the Content-Type header (cURL's default is application/x-www-form-urlencoded). You can do this with -H. For example, if you wanted to make a POST request with a JSON body:

$ curl -d 'json body' -H 'Content-Type: application/json' URL

参照