commit
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package netx
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
)
|
||||
|
||||
// 获取http原始报文
|
||||
|
||||
func GetHttpOrigin() {
|
||||
resp, err := http.Get("https://baidu.com")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
d, err := httputil.DumpRequestOut(resp.Request, true)
|
||||
fmt.Println(string(d))
|
||||
|
||||
dump, err := httputil.DumpResponse(resp, true)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
dd, err := httputil.DumpRequest(resp.Request, true)
|
||||
fmt.Println(string(dd))
|
||||
|
||||
fmt.Printf("%q", dump)
|
||||
}
|
||||
Reference in New Issue
Block a user