http - 在 go net/http 中获取 http body

标签 http go

我想使用 go 获取 http 正文数据。
我的演示: enter image description here

我在http请求头中设置了Content-Type: application/x-www-form-urlencoded,没有报错,但是获取不到http body数据。 像这样的 Http 请求数据: enter image description here

我只想获取 http 主体,我不想使用方法 request.FormValue。我该怎么办?

最佳答案

在读取表单值之前调用ParseForm

r.ParseForm()
for k, v := range r.Form {
    fmt.Println(k, v)
}

关于http - 在 go net/http 中获取 http body,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53777839/

相关文章:

http - haskell wreq 参数列表

javascript - 如何评估 fetch api 中收到的 http 响应

go - 用于检测 CGO 构建的预处理器标志?

go - 无法在 '/find/{id}' 下触发 API 端点执行

angular - 如何测试依赖于另一个服务的服务/组件又依赖于 Http 服务?

HTTP 1.1 TE header

测试时Golang "plugin was built with a different version of package"

regex - 正则表达式在括号之间获取值

c++ - golang Alpine docker交叉编译C++

ruby - 将 HTTP 响应放入 Ruby on Rails 应用程序的哪个文件?