doucu7525 2014-03-12 05:17
浏览 896
已采纳

http请求中的转义感叹号

I have a URL like

http://app.chat.com/avert!Callbcak.htm

to request.

I created the request with golang

req, _ := http.NewRequest("GET", "http://app.chat.com/avert!Callbcak.htm", nil)
fmt.Printf("%v
", req.URL.String())

result is

http://app.chat.com/avert%21Callbcak.htm

which is not going to work, the website needs URL that exclamation mark not escaped.

How can I request that URL correctly?

  • 写回答

2条回答 默认 最新

  • dou47732 2014-03-18 06:03
    关注

    finally I found answer here

    I process the request before sending:

    func (s *Sender) regulateRequestURL(req *http.Request) {
        if strings.Contains(req.URL.Path, "!") {
            req.URL.Opaque = fmt.Sprintf("//%s%s", req.URL.Host, req.URL.Path)
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?