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
Issue is seen in online editor of https://go.dev/play/.
What did you do?
Below program o/p is giving different o/p with calls to req.URL.RequestURI().
First time o/p is printing unescaped URL. But Second time call is giving escaped URL.
It should be consistent.
package main
import (
"fmt"
"net/http"
)
func main() {
// Get the full request URI
req, _ := http.NewRequest("GET", "http://example.com/a%2Fv", nil)
// Print the request URI
fmt.Println("Request URI: \n", req.URL.RequestURI())
req.URL.Path = "a%2Fv"
fmt.Println("After URI: \n", req.URL.RequestURI())
}
O/p:
Request URI:
/a%2Fv
After URI:
a%252Fv
What did you see happen?
Above sample program o/p is giving different o/p with calls to req.URL.RequestURI().
First time o/p is printing unescaped URL. But Second time call is giving escaped URL.
It should be consistent.
What did you expect to see?
Both the times calling req.URL.RequestURI() should provide same kind of URL(either escaped or unescaped).
O/p should be consistent.
O/p seen is:
Request URI:
/a%2Fv
After URI:
a%252Fv
The text was updated successfully, but these errors were encountered:
see the documentation for net/URL.URL for the expected format of the Path field.
closing as not a bug.
Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.
Go version
go1.22
Output of
go env
in your module/workspace:Issue is seen in online editor of https://go.dev/play/.
What did you do?
Below program o/p is giving different o/p with calls to req.URL.RequestURI().
First time o/p is printing unescaped URL. But Second time call is giving escaped URL.
It should be consistent.
package main
import (
"fmt"
"net/http"
)
func main() {
// Get the full request URI
req, _ := http.NewRequest("GET", "http://example.com/a%2Fv", nil)
// Print the request URI
fmt.Println("Request URI: \n", req.URL.RequestURI())
req.URL.Path = "a%2Fv"
fmt.Println("After URI: \n", req.URL.RequestURI())
}
O/p:
Request URI:
/a%2Fv
After URI:
a%252Fv
What did you see happen?
Above sample program o/p is giving different o/p with calls to req.URL.RequestURI().
First time o/p is printing unescaped URL. But Second time call is giving escaped URL.
It should be consistent.
What did you expect to see?
Both the times calling req.URL.RequestURI() should provide same kind of URL(either escaped or unescaped).
O/p should be consistent.
O/p seen is:
Request URI:
/a%2Fv
After URI:
a%252Fv
The text was updated successfully, but these errors were encountered: