Linuxでは、「curl -k -i -X」とはどういう意味ですか?

Linuxでは、「curl -k -i -X」とはどういう意味ですか?

マニュアルページを読みCurlましたが、これらのパラメータ(k、i、X)の意味は理解できません。 REST API呼び出しに使用されているのを見ましたが、これら3つのパラメータの機能を説明できる人はいますか?文書には明確ではありません。

よろしくお願いします。

ベストアンサー1

-k、--安全ではありません:使用しているウェブサイトをカーリングしたい場合自己署名SSL証明書これにより、カールがエラーを引き起こしますカールは証明書を検証できません。この場合、以下を使用するか-kタグ--insecureを付けることができます。証明書の確認をスキップ

例:

[root@arif]$ curl --head https://xxx.xxx.xxx.xxx/login

curl: (60) Peer's Certificate issuer is not recognized. 
More details here: http://curl.haxx.se/docs/sslcerts.html 
curl performs SSL certificate verification by default, using a 
"bundle" of Certificate Authority (CA) public keys (CA certs).
If the default bundle file isn't adequate, you can specify an 
alternate file using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented 
in the bundle, the certificate verification probably failed 
due to a problem with the certificate (it might be expired, 
or the name might not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate,
use the -k (or --insecure) option.

[root@arif]$ curl -k --head https://xxx.xxx.xxx.xxx/login

HTTP/1.1 302 Moved Temporarily
Date: Thu, 07 Dec 2017 04:53:44 GMT
Transfer-Encoding: chunked
Location: https://xxx.xxx.xxx.xxx/login 
X-FRAME-OPTIONS: SAMEORIGIN
Set-Cookie: JSESSIONID=xxxxxxxxxxx; path=/; HttpOnly

-i, --include:このフラグにはhttpヘッダーが含まれています。通常、httpヘッダーはサーバー名、日付、コンテンツタイプなどで構成されています。

例:

[root@arif]$ curl https://google.com

<HTML><HEAD><meta http-equiv="content-type" content="text/html charset=utf-8"> <TITLE>301 Moved</TITLE></HEAD><BODY> <H1>301 Moved</H1> The document has moved <A HREF="https://www.google.com/">here</A>. </BODY></HTML>

[root@arif]$ curl -i https://google.com

HTTP/1.1 301 Moved Permanently
Location: https://www.google.com/
Content-Type: text/html; charset=UTF-8
Date: Thu, 07 Dec 2017 05:13:44 GMT
Expires: Sat, 06 Jan 2018 05:13:44 GMT
Cache-Control: public, max-age=2592000
Server: gws
Content-Length: 220
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
Alt-Svc: hq=":443"; ma=2592000; quic=51303431; quic=51303339;
quic=51303338; quic=51303337; quic=51303335,quic=":443"; ma=2592000;
v="41,39,38,37,35"
<HTML><HEAD><meta http-equiv="content-.....

-X, --リクエスト:このフラグは、サーバーにカスタム要求を送信するために使用されます。ほとんどの場合、、GETおよびHEADを実行しますPOST。ただし、たとえば特定の要求が必要な場合は、PUTこのフラグを使用できます。次の例では、google.com に削除リクエストを送信します。FTPDELETE

例:

[root@arif]$ curl -X DELETE google.com

..........................
<p><b>405.</b> <ins>That’s an error.</ins>
<p>The request method <code>DELETE</code> is inappropriate for the URL
<code>/</code>.  <ins>That’s all we know.</ins>`

おすすめ記事