【问题标题】:How to disable redirection when using net/http POST使用 net/http POST 时如何禁用重定向
【发布时间】:2022-06-16 00:42:57
【问题描述】:

我需要使用golang登录我的openwrt路由器后端,登录返回不是cookie而是302页面重定向,如果直接发送请求将触发403,我也在http调试工具上调试,我需要禁止重定向到在返回标头中获取cookie值,如果默认他将显示403,如果我不允许重定向将显示302,那么,当我使用net / http发送请求时有没有办法禁用重定向

:)

chrome img

func login() {
    rq, _ := http.NewRequest("POST", "http://10.0.0.1/cgi-bin/luci/", strings.NewReader("luci_username=root&luci_password=password"))
    rq.Header.Add("Content-Type", "application/x-www-form-urlencoded")

    rs, _ := http.DefaultClient.Do(rq)

    // out, _ := ioutil.ReadAll(rs.Body)
    out := rs.Header
    fmt.Printf("%s", out)
}

【问题讨论】:

标签: http go post


猜你喜欢
  • 1970-01-01
  • 2020-03-20
  • 1970-01-01
  • 1970-01-01
  • 2016-10-06
  • 2016-06-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多