You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a small program trying to download the following file, via http.Get:
http://www.sfmta.com/cms/uploadedfiles/dpt/bike/Safety/Chapter%202_General%
20Bicycle%20Rules.pdf
When http.Get handles the url, the combination of http.URLUnescape (in
http.ParseURL) and http.URLEscape (in req.Write) converts the url into
this:
http://www.sfmta.com/cms/uploadedfiles/dpt/bike/Safety/Chapter+2_General+Bi
cycle+Rules.pdf
However, that link returns a 404.
Is there a reason why %20 is converted to '+'? Would it be safer to use
%20?
Relevant code is here:
package main
import "http"
func main() {
rawurl :=
`http://www.sfmta.com/cms/uploadedfiles/dpt/bike/Safety/Chapter%202_General
%20Bicy
cle%20Rules.pdf`
url,err := http.ParseURL (rawurl )
if err != nil {
println("error parsing", err)
}
println("Final url", url.String())
resp,_,err := http.Get ( rawurl )
if err != nil {
println("error downlaoding", err.String())
}
println(resp.StatusCode);
}
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: