
다음과 같은 원시 형식의 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
, httpie
또는 다른 CLI HTTP 클라이언트를 사용하여 원시 데이터에서 HTTP 요청을 만들려면 어떻게 해야 합니까?
답변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.