client.URL or client.BaseURL undefined behavior
1Feng opened this issue · 0 comments
1Feng commented
client.URL or client.BaseURL with empty host but port will send request to localhost
for example:
// Create a new client
cli := gentleman.New()
// Define the Base URL
// when host is empty, but port, there will cause an undefined behavior
// cli.BaseURL(fmt.Sprintf("http://%s:%s", host, port))
cli.BaseURL("http://:8889") // or cli.URL("http://:8889")
// fmt.Println(cli.Context.Request.URL.String())
// Create a new request based on the current client
req := cli.Request()
// Method to be used
req.Method("POST")
// Define the JSON payload via body plugin
data := map[string]string{"foo": "bar"}
req.Use(body.JSON(data))
// Perform the request, then it will send request to localhost
res, err := req.Send()