-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
r2
sends invalid HTTP requests if Path
does not have a leading /
.
#154
Comments
The equivalent with package main
import (
"fmt"
"time"
"github.com/blend/go-sdk/request"
)
func mustNil(err error) {
if err != nil {
panic(err)
}
}
func main() {
r := request.New().
WithScheme("http").
WithHost("localhost:5007").
WithPath("v1/resource").
WithTimeout(5 * time.Second)
res, err := r.Response()
mustNil(err)
fmt.Printf("%#v\n", res)
// // Using r.Response() is equivalent to the following:
// req, err := r.Request()
// mustNil(err)
// client := &http.Client{Timeout: r.Timeout()}
// res, err := client.Do(req)
// mustNil(err)
} produces
|
One particular peculiarity is that package main
import (
"fmt"
"net/url"
)
func main() {
u := &url.URL{
Scheme: "https",
Host: "site.invalid",
Path: "v1/dogs",
RawQuery: "a=b",
}
fmt.Printf("%q (%#v)\n", u.String(), u)
u = &url.URL{
Scheme: "https",
Host: "site.invalid",
Path: "/v1/dogs",
RawQuery: "a=b",
}
fmt.Printf("%q (%#v)\n", u.String(), u)
} we get the same URL string even though
|
just happened for me too on existing api requests |
That is right. In this usage, the parameter However in |
To reproduce (at 480ad70), first listen to port 5007 with netcat and then run this sample program
After running, we have
I will dig deeper into this at a later time, but just wanted to get the repro posted here.
The text was updated successfully, but these errors were encountered: