LoginSignup
2
1

More than 3 years have passed since last update.

curl の無い container (alpine) 内から POST リクエストを送る方法 / Fire POST request without curl

Posted at

https://www.reddit.com/r/bash/comments/2vt3p1/make_a_post_request_without_curl/coksadc/ ここにあった。

netcat (nc) を使えば良い?

(他のやり方もありそうとはいえ)

以下は GET の場合だが。

% docker run -it alpine:3.9.4 sh -c 'echo -e "GET / HTTP/1.0\nHost: example.com\n\n" | nc example.com 80'

HTTP/1.0 200 OK
Accept-Ranges: bytes
Age: 556620
Cache-Control: max-age=604800
Content-Type: text/html; charset=UTF-8
Date: Thu, 15 Apr 2021 00:23:33 GMT
Etag: "3147526947"
Expires: Thu, 22 Apr 2021 00:23:33 GMT
Last-Modified: Thu, 17 Oct 2019 07:18:26 GMT
Server: ECS (sjc/4E76)
Vary: Accept-Encoding
X-Cache: HIT
Content-Length: 1256
Connection: close

<!doctype html>
<html>
<head>
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1