Http
設置 HTTP 請求記錄器的最簡單方法是什麼
在本地設置以偵聽自定義埠上的 GET 請求的最簡單方法是什麼?
這樣我就可以做到
curl -X GET -i 'localhost:34331/hello'
並驗證是否收到了請求並檢查請求以查看標頭是否已發送以及用於請求的 URL
你可以使用netcat。就像是:
nc -l 34331
如果您想查看通話的詳細資訊,使用
-v
curl 選項並呼叫真實服務會更容易。curl -v http://www.google.com > /dev/null * Connected to localhost (127.0.0.1) port 3128 (#0) > GET http://www.google.com/ HTTP/1.1 > Host: www.google.com > User-Agent: curl/7.47.0 > Accept: */* > Proxy-Connection: Keep-Alive > < HTTP/1.1 200 OK < Date: Fri, 22 Jun 2018 12:58:58 GMT < Expires: -1 < Cache-Control: private, max-age=0 < P3P: CP="This is not a P3P policy! See g.co/p3phelp for more info." < Server: gws < X-XSS-Protection: 1; mode=block < X-Frame-Options: SAMEORIGIN < Set-Cookie: 1P_JAR=2018-06-22-12; expires=Sun, 22-Jul-2018 12:58:58 GMT; path=/; domain=.google.com < Set-Cookie: NID=132=cLF8pa3SHRsg32-ZGzN5aZ3ipLfAbxqfmUvJ2NTvkYg2eWN6XaOqSofMK7o902-C9hdxL_wUn6cJW2AkngcQXvNUKCCdNi7Z-eBTu0Yc8-iTFR90OeZDR44hxZK95_Ny; expires=Sat, 22-Dec-2018 12:58:58 GMT; path=/; domain=.google.com; HttpOnly < Accept-Ranges: none < Vary: Accept-Encoding < Transfer-Encoding: chunked < Content-Type: text/html; charset=ISO-8859-1 < Connection: keep-alive < Proxy-Connection: keep-alive < { [2035 bytes data] 100 11564 0 11564 0 0 69134 0 --:--:-- --:--:-- --:--:-- 68833 * Connection #0 to host localhost left intact