cURL

提供: ArchWiki
2021年8月8日 (日) 14:08時点におけるKusanaginoturugi (トーク | 投稿記録)による版 (新規作成(英語版より転載))
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
ナビゲーションに移動 検索に移動

cURL is a command line tool and library for transferring data with URLs. The command supports a number of different protocols, including HTTP, HTTPS, FTP, SCP, and SFTP. It is also designed to work without user interaction, like in scripts.

Installation

Install the curl package.

Usage

Downloading

A common use case for cURL is to download the resource to a specified file:

$ curl -o file name URL

If the URL contains the file name, you can save the resource directly to a file of that name:

$ curl -O URL

Similarly, you can use -J to accept a hint from an HTTP server (from the Content-Disposition header) for what the file should be named. If combined with -O, curl will use the file name specified by the URL if the HTTP server does not return a file name hint in its response.

Alternatively you can print the resource to stdout by omitting the output options:

$ 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

See also