curl

curl はホスティング側から HTTP/HTTPS リクエストを送り、ステータス・ヘッダー・本文を表示し、メソッド、データ、Cookie、Basic Auth を扱い、応答の保存やエディター表示もできます。

ネットワークバージョン 1.2.5安定版
lil-terminal

概要

リモートエンドポイントがサーバー側からどう見えるか確認したいときに curl を使います。API、リダイレクト、ヘッダー、IPv4/IPv6、応答の保存をシステムシェルなしで確認できます。

リクエスト、レスポンス、実行場所

curl はローカルブラウザーではなくホスティングサーバー上で実行されます。まず単純な GET またはヘッダーだけを確認し、本文・認証・診断フラグは必要な場合だけ追加します。-k は証明書検証を意図的に無効化します。

構文

lil-terminal
curl <url|host|me> [options]

リファレンス

curl me

現在のホストを使用する

curl example.com

GET リクエストを送信して状態と本文を表示する

curl example.com -I

最終レスポンスヘッダーだけを表示する

curl example.com -s [file]

レスポンスを保存する; 省略時は URL のファイル名を使用する

curl example.com -X POST -d "a=1"

リクエスト本文を送信する

-X <method>

HTTP メソッドを設定する

-d <data>

リクエスト本文を設定する; 既定は POST

-H "Name: value"

リクエストヘッダーを追加する; 複数回指定可能

-u <user>

非表示のパスワード入力で HTTP Basic 認証を使用する

-c '{"name":"value"}'

JSON オブジェクトから cookie を送信する

-s [file] | -o <file>

ホスト上にレスポンスを保存する

-a

置換せず追記する; -s または -o が必要

-i

最終レスポンスヘッダーを含める

-I

最終レスポンスヘッダーだけを表示する

-j

レスポンスを構造化 JSON で表示する

-edit @edit

レスポンス本文をテキストエディターで開く

-code @code

レスポンス本文をコードエディターで開く

-t [seconds]

5 秒または 1 から 300 秒の任意のタイムアウトを使用する

-T

300 秒のタイムアウトを使用する

-4 | -6

cURL が利用可能な場合に IPv4 または IPv6 を使用する

-r

リダイレクトを追跡しない

-k

安全でない TLS 証明書を許可する

実際の使い方

まず curl example.com で応答を確認し、ヘッダーだけなら -I を使います。-i は本文とヘッダー、-j は構造化 JSON を表示します。API には -X、-d、複数の -H を使えます。-s/-o はサーバーのファイルへ保存し、-a は追記します。-edit/-code はテキストをエディターで開きます。

制限と安全

-u <user> はパスワードを別入力で求めますが、-d の内容や cookie は履歴に残る場合があります。標準で TLS 証明書を検証し、最大 5 回リダイレクトします。-k は検証を無効に、-r はリダイレクトを無効にします。PHP cURL がない場合も通常のリクエストは PHP streams で動作しますが、-4/-6 は cURL が必要です。表示上限 8 MiB、保存上限 256 MiB。内部サービスを含め、許可された宛先のみを使ってください。例は学習用の固定データです。

IPv4/IPv6 の明示的な確認

PHP cURL がない場合、curl -4/-6 はアドレス種別を無視せず明確にエラーを返します。

インタラクティブな sandbox プレビュー

用意された例をページ上でそのまま実行できます。結果は事前に生成されてブラウザに表示され、サーバーではターミナルコマンドを実行しません。

ヘッダーを確認してから応答を保存する

インストールと管理

現在の互換バージョンをインストールします。全機能は Base、縮小版は Minimum を選び、すでに導入済みのモジュール更新には upgrade を使います。

Base と Minimum は同じ現在のモジュールリリースの二つのパッケージです。

Base パッケージ

ローカル参照と公開済みの全モードを含む完全パッケージをインストールします。

install curl
Minimum パッケージ

縮小パッケージをインストールします。ローカルリファレンスは含まれず、help <cmd> -i で現在のサーバーリファレンスを開きます。

install curl -m
正確な公開版

この公開済みバージョンを正確に指定してインストールします。

install curl -v 1.2.5
確認または更新

upgrade が互換性を確認し、必要な場合だけブロックを置換します。

upgrade curl
モジュールを削除

コアや他のモジュールに触れず拡張ブロックを削除します。

install curl -u

例

例はコピーできますが、サイトは実行しません。実プロジェクトではパス、権限、破壊的オプションを確認してください。

ヘッダーを確認してから応答を保存する
curl https://example.com
ネットワーク学習用例 — 実際の通信なし
HTTP:		200
URL:		https://example.com/

<!doctype html>
<html>…</html>
現在のホストを使用する
curl me
ネットワーク学習用例 — 実際の通信なし
HTTP:		200
URL:		https://example.com/

<!doctype html>
<html>…</html>
最終レスポンスヘッダーだけを表示する
curl https://example.com -I
ネットワーク学習用例 — 実際の通信なし
HTTP/2 200
content-type: text/html; charset=UTF-8
cache-control: max-age=86000
最終レスポンスヘッダーを含める
curl https://example.com -i
ネットワーク学習用例 — 実際の通信なし
HTTP/2 200
content-type: text/html; charset=UTF-8

<!doctype html>
<html>…</html>
レスポンスを構造化 JSON で表示する
curl https://example.com -j
ネットワーク学習用例 — 実際の通信なし
{
  "status": 200,
  "url": "https://example.com/",
  "headers": [
    "HTTP/2 200",
    "content-type: text/html; charset=UTF-8"
  ],
  "body": "<html>…</html>"
}
リクエスト本文を送信する
curl https://example.com -X POST -d "name=lil"
ネットワーク学習用例 — 実際の通信なし
HTTP: 200
URL: https://example.com/

Example response to a POST request; the server may reject POST or return another status.
リクエスト本文を設定する; 既定は POST
curl https://example.com -d "name=lil"
ネットワーク学習用例 — 実際の通信なし
HTTP: 200
URL: https://example.com/

Example response to a POST request; the server may reject POST or return another status.
リクエストヘッダーを追加する; 複数回指定可能
curl https://example.com -H "Accept: application/json"
ネットワーク学習用例 — 実際の通信なし
HTTP: 200
URL: https://example.com/

Request contains custom headers; the remote reply depends on the endpoint.
リクエストヘッダーを追加する; 複数回指定可能
curl https://example.com -H "Accept: application/json" -H "X-Demo: 1"
ネットワーク学習用例 — 実際の通信なし
HTTP: 200
URL: https://example.com/

Request contains custom headers; the remote reply depends on the endpoint.
JSON オブジェクトから cookie を送信する
curl https://example.com -c '{"theme":"dark"}'
ネットワーク学習用例 — 実際の通信なし
HTTP: 200
URL: https://example.com/

Request includes Cookie: theme=dark; the server decides how to respond.
非表示のパスワード入力で HTTP Basic 認証を使用する
curl https://example.com -u demo
ネットワーク学習用例 — 実際の通信なし
A separate secret-password prompt appears before the request is sent.
レスポンスを保存する; 省略時は URL のファイル名を使用する
curl https://example.com -s
ネットワーク学習用例 — 実際の通信なし
sandbox/
  index.html
The response body is saved on the hosting account.
未対応のプロトコルを拒否する
curl https://example.com -s tmp/example.html
ネットワーク学習用例 — 実際の通信なし
sandbox/tmp/
  example.html
The response body is saved on the hosting account.
ホスト上にレスポンスを保存する
curl https://example.com -o tmp/example.html
ネットワーク学習用例 — 実際の通信なし
sandbox/tmp/
  example.html
The response body is saved on the hosting account.
置換せず追記する; -s または -o が必要
curl https://example.com -o tmp/example.html -a
ネットワーク学習用例 — 実際の通信なし
sandbox/tmp/
  example.html
The body is appended to the existing file.
5 秒または 1 から 300 秒の任意のタイムアウトを使用する
curl https://example.com -t
ネットワーク学習用例 — 実際の通信なし
HTTP: 200
URL: https://example.com/

Timeout option changes the maximum wait, not the response format.
5 秒または 1 から 300 秒の任意のタイムアウトを使用する
curl https://example.com -t 2
ネットワーク学習用例 — 実際の通信なし
HTTP: 200
URL: https://example.com/

Timeout option changes the maximum wait, not the response format.
300 秒のタイムアウトを使用する
curl https://example.com -T
ネットワーク学習用例 — 実際の通信なし
HTTP: 200
URL: https://example.com/

Timeout option changes the maximum wait, not the response format.
CURL が利用可能な場合に IPv4 または IPv6 を使用する
curl https://example.com -4
ネットワーク学習用例 — 実際の通信なし
HTTP: 200
URL: https://example.com/

Requested IP family IPv4 (requires PHP cURL).
CURL が利用可能な場合に IPv4 または IPv6 を使用する
curl https://example.com -6
ネットワーク学習用例 — 実際の通信なし
HTTP: 200
URL: https://example.com/

Requested IP family IPv6 (requires PHP cURL).
リダイレクトを追跡しない
curl https://example.com -r
ネットワーク学習用例 — 実際の通信なし
HTTP: 200
URL: https://example.com/

Redirect following disabled; response status depends on endpoint.
安全でない TLS 証明書を許可する
curl https://example.com -k
ネットワーク学習用例 — 実際の通信なし
HTTP: 200
URL: https://example.com/

Certificate verification disabled for this diagnostic request.
レスポンス本文をテキストエディターで開く
curl https://example.com -edit
ネットワーク学習用例 — 実際の通信なし
The installed text editor opens the response in a protected temporary file.
レスポンス本文をコードエディターで開く
curl https://example.com -code
ネットワーク学習用例 — 実際の通信なし
The installed code editor opens the response in a protected temporary file.
レスポンスを構造化 JSON で表示する
curl https://example.com -j -code
ネットワーク学習用例 — 実際の通信なし
The installed code editor opens the response in a protected temporary file as formatted JSON.
レスポンス本文をテキストエディターで開く
curl https://example.com -edit -s tmp/example.html
ネットワーク学習用例 — 実際の通信なし
Editor mode cannot be combined with -s or -o
置換せず追記する; -s または -o が必要
curl https://example.com -a
ネットワーク学習用例 — 実際の通信なし
Append requires an output file
Curl · com
curl ftp://example.com
ネットワーク学習用例 — 実際の通信なし
Invalid URL
CURL が利用可能な場合に IPv4 または IPv6 を使用する
curl https://example.com -4 -6
ネットワーク学習用例 — 実際の通信なし
Choose either IPv4 or IPv6
HTTP メソッドを設定する
curl https://example.com -X 9bad
ネットワーク学習用例 — 実際の通信なし
Invalid HTTP method
リクエストヘッダーを追加する; 複数回指定可能
curl https://example.com -H "broken"
ネットワーク学習用例 — 実際の通信なし
Invalid header
JSON オブジェクトから cookie を送信する
curl https://example.com -c not-json
ネットワーク学習用例 — 実際の通信なし
Invalid cookie JSON
5 秒または 1 から 300 秒の任意のタイムアウトを使用する
curl https://example.com -t 301
ネットワーク学習用例 — 実際の通信なし
Invalid timeout
ホスト上にレスポンスを保存する
curl https://example.com -o
ネットワーク学習用例 — 実際の通信なし
Output file required
レスポンス本文をテキストエディターで開く
curl https://example.com -edit -code
ネットワーク学習用例 — 実際の通信なし
Choose one editor

関連ドキュメント

現在の公開版

v1.2.52026-10-31

IPv4/IPv6 の明示的な確認

PHP cURL がない場合、curl -4/-6 はアドレス種別を無視せず明確にエラーを返します。