2014-03-12 05:17



I have a URL like!Callbcak.htm

to request.

I created the request with golang

req, _ := http.NewRequest("GET", "!Callbcak.htm", nil)
", req.URL.String())

result is

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

How can I request that URL correctly?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dou47732 dou47732 7年前

    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)
    点赞 评论 复制链接分享
  • dsaj20411 dsaj20411 7年前


    Section 2, on characters, has been rewritten to explain what
    characters are reserved, when they are reserved, and why they are
    reserved, even when they are not used as delimiters by the generic
    syntax. The mark characters that are typically unsafe to decode,
    including the exclamation mark ("!"), asterisk ("*"), single-quote
    ("'"), and open and close parentheses ("(" and ")"), have been moved
    to the reserved set in order to clarify the distinction between
    reserved and unreserved and, hopefully, to answer the most common
    question of scheme designers. Likewise, the section on
    percent-encoded characters has been rewritten, and URI normalizers
    are now given license to decode any percent-encoded octets

    This means that ! is an unfortunate choice of a separator because although the grammar allows its use in segment (as part of the pchar non-terminal) it is also a part of the reserved non-terminal.

    As I read it the RFC is slightly ambivalent about ! reservedness, depending upon the context in which it is used.

    Escaping the character seems the most safe assumption to make since the recipient is "licenced to decode the percent-encoded octet". You should consider using another separator or decoding the entity on the endpoint.

    点赞 评论 复制链接分享