Skip to content
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

client.URL or client.BaseURL undefined behavior #41

Open
1Feng opened this issue Feb 27, 2018 · 0 comments
Open

client.URL or client.BaseURL undefined behavior #41

1Feng opened this issue Feb 27, 2018 · 0 comments

Comments

@1Feng
Copy link

1Feng commented Feb 27, 2018

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()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant