• Russ Cox's avatar
    net/url: add RawPath field, a hint at the desired encoding of Path · 874a605a
    Russ Cox authored
    Historically we have declined to try to provide real support for URLs
    that contain %2F in the path, but they seem to be popping up more
    often, especially in (arguably ill-considered) REST APIs that shoehorn
    entire paths into individual path elements.
    
    The obvious thing to do is to introduce a URL.RawPath field that
    records the original encoding of Path and then consult it during
    URL.String and URL.RequestURI. The problem with the obvious thing
    is that it breaks backward compatibility: if someone parses a URL
    into u, modifies u.Path, and calls u.String, they expect the result
    to use the modified u.Path and not the original raw encoding.
    
    Split the difference by treating u.RawPath as a hint: the observation
    is that there are many valid encodings of u.Path. If u.RawPath is one
    of them, use it. Otherwise compute the encoding of u.Path as before.
    
    If a client does not use RawPath, the only change will be that String
    selects a different valid encoding sometimes (the original passed
    to Parse).
    
    This ensures that, for example, HTTP requests use the exact
    encoding passed to http.Get (or http.NewRequest, etc).
    
    Also add new URL.EscapedPath method for access to the actual
    escaped path. Clients should use EscapedPath instead of
    reading RawPath directly.
    
    All the old workarounds remain valid.
    
    Fixes #5777.
    Might help #9859.
    Fixes #7356.
    Fixes #8767.
    Fixes #8292.
    Fixes #8450.
    Fixes #4860.
    Fixes #10887.
    Fixes #3659.
    Fixes #8248.
    Fixes #6658.
    Reduces need for #2782.
    
    Change-Id: I77b88f14631883a7d74b72d1cf19b0073d4f5473
    Reviewed-on: https://go-review.googlesource.com/11302Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    874a605a
Name
Last commit
Last update
..
archive Loading commit data...
bufio Loading commit data...
builtin Loading commit data...
bytes Loading commit data...
cmd Loading commit data...
compress Loading commit data...
container Loading commit data...
crypto Loading commit data...
database/sql Loading commit data...
debug Loading commit data...
encoding Loading commit data...
errors Loading commit data...
expvar Loading commit data...
flag Loading commit data...
fmt Loading commit data...
go Loading commit data...
hash Loading commit data...
html Loading commit data...
image Loading commit data...
index/suffixarray Loading commit data...
internal Loading commit data...
io Loading commit data...
log Loading commit data...
math Loading commit data...
mime Loading commit data...
net Loading commit data...
os Loading commit data...
path Loading commit data...
reflect Loading commit data...
regexp Loading commit data...
runtime Loading commit data...
sort Loading commit data...
strconv Loading commit data...
strings Loading commit data...
sync Loading commit data...
syscall Loading commit data...
testing Loading commit data...
text Loading commit data...
time Loading commit data...
unicode Loading commit data...
unsafe Loading commit data...
Make.dist Loading commit data...
all.bash Loading commit data...
all.bat Loading commit data...
all.rc Loading commit data...
androidtest.bash Loading commit data...
bootstrap.bash Loading commit data...
buildall.bash Loading commit data...
clean.bash Loading commit data...
clean.bat Loading commit data...
clean.rc Loading commit data...
iostest.bash Loading commit data...
make.bash Loading commit data...
make.bat Loading commit data...
make.rc Loading commit data...
nacltest.bash Loading commit data...
race.bash Loading commit data...
race.bat Loading commit data...
run.bash Loading commit data...
run.bat Loading commit data...
run.rc Loading commit data...