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?
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)
}
}
From http://tools.ietf.org/html/rfc3986
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.