美文网首页
golang request.go中PostForm和Form区

golang request.go中PostForm和Form区

作者: 東玖零 | 来源:发表于2021-10-13 18:31 被阅读0次
    // Form contains the parsed form data, including both the URL
    // field's query parameters and the PATCH, POST, or PUT form data.
    // This field is only available after ParseForm is called.
    // The HTTP client ignores Form and uses Body instead.
    Form url.Values
    
    // PostForm contains the parsed form data from PATCH, POST
    // or PUT body parameters.
    //
    // This field is only available after ParseForm is called.
    // The HTTP client ignores PostForm and uses Body instead.
    PostForm url.Values
    

    上面是从源码复制得出。

    Form属性包含了post表单和url后面跟的get参数。

    PostForm属性只包含了post表单参数。

    实践数据如下:

    打印请求头:

    headers [map[Accept:[*/*] Accept-Encoding:[gzip;q=1.0, compress;q=0.5] Accept-Language:[en;q=1.0] Connection:[keep-alive] Content-Length:[211] Content-Type:[application/x-www-form-urlencoded; charset=utf-8] User-Agent:[xxx/1.0.0 (xxx; build:1.0.0; iOS 15.0.0) Alamofire/4.7.3]]
    
    

    打印Form和PostForm

    ---->PostForm= map[account:[adong] orgIds:[%22128%22%2C%22105%22%2C%22424%] sign:[16af446b718e3663e53b8466f545898988487a20557a3]] 
    
    ---->Form= map[account:[adong] cts:[1634120339] uid:[123] orgIds:[%22128%22%2C%22105%22%2C%22424%] os:[ios] sign:[16af446b718e3663e53b8466f545898988487a20557a3] v:[1.0.0]] 
    
    

    客户端打印:

    url:/org/get_org_list?uid=123&v=1.0.0&cts=1634120339&os=ios
    paras: {"account": "adong", "orgIds": "%22128%22%2C%22105%22%2C%22424%", "sign": "16af446b718e3663e53b8466f545898988487a20557a3"}
    

    相关文章

      网友评论

          本文标题:golang request.go中PostForm和Form区

          本文链接:https://www.haomeiwen.com/subject/uxceoltx.html