W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
?http
?客戶端支持對?HTTP
?請求的輸入與輸出原始信息獲取與打印,方便調(diào)試,相關(guān)方法如下:
func (r *Response) Raw() string
func (r *Response) RawDump()
func (r *Response) RawRequest() string
func (r *Response) RawResponse() string
可以看到,所有的方法均綁定在?Response
?對象上,也就是說必須要請求結(jié)束后才能打印。
package main
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gctx"
)
func main() {
response, err := g.Client().Post(
gctx.New(),
"https://goframe.org",
g.Map{
"name": "john",
},
)
if err != nil {
panic(err)
}
response.RawDump()
}
執(zhí)行后,終端輸出為:
+---------------------------------------------+
| REQUEST |
+---------------------------------------------+
POST / HTTP/1.1
Host: goframe.org
User-Agent: GoFrameHTTPClient v2.0.0-beta
Content-Length: 9
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip
name=john
+---------------------------------------------+
| RESPONSE |
+---------------------------------------------+
HTTP/1.1 405 Method Not Allowed
Connection: close
Transfer-Encoding: chunked
Allow: GET
Cache-Control: no-store
Content-Security-Policy: frame-ancestors 'self'
Content-Type: text/html;charset=UTF-8
Date: Fri, 03 Dec 2021 09:43:29 GMT
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Server: nginx
...
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: