我有一些原始格式的 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)
我必须测试和调试它们,因为这个原因我需要一种简单的方法来在我的计算机上重复它们,如何使用 或另一个 CLI HTTP 客户端从原始数据发出 HTTPcurl
请求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.