
次のような生の形式のHTTPリクエストがあります。
GET /docs/index.html HTTP/1.1
Host: www.nowhere123.com
Accept: image/gif, image/jpeg, */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
(blank line)
curl
このため、テストとデバッグを行う必要があるため、コンピューター上で簡単に繰り返す方法が必要です。、または別の CLI HTTP クライアントを使用して、生データから HTTP 要求を行うにはどうすればよいですかhttpie
?
答え1
私は telnet: をお勧めします。telnet www.nowhere123.com 80
これにより、サーバーに直接通信できます。
例:
telnet 127.0.0.1 80
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
GET /index.htm
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="https:///index.htm">here</a>.</p>
</body></html>
Connection closed by foreign host.