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] Parameters are not sent from >= v0.17.1 #1925

Closed
Spixmaster opened this issue Sep 7, 2024 · 3 comments
Closed

[Client] Parameters are not sent from >= v0.17.1 #1925

Spixmaster opened this issue Sep 7, 2024 · 3 comments

Comments

@Spixmaster
Copy link

Spixmaster commented Sep 7, 2024

std::int32_t main()
{
        httplib::Client client("localhost", 5286);
        const httplib::Result result = client.Get(
          "/something",
          httplib::Params({
            {"some-parameter", "178"}
        }),
          {{}});
}

The parameter is not sent. It only works if the HTTP Headers have actual content.

This works.

std::int32_t main()
{
        httplib::Client client("localhost", 5286);
        const httplib::Result result = client.Get(
          "/something",
          httplib::Params({
            {"some-parameter", "178"}
        }),
          {{"asdf", "asdf"}});
}

The bug was introduced with version 0.17.1 and is still persistent with v0.17.3.

@yhirose
Copy link
Owner

yhirose commented Sep 7, 2024

@Spixmaster thanks for the report. Could you give me more details? It seems like it is caused by #1908.

@yhirose
Copy link
Owner

yhirose commented Sep 7, 2024

I confirmed this behavior is caused by #1908, but this is a correct behavior. The code should be as below.

std::int32_t main()
{
        httplib::Client client("localhost", 5286);
        const httplib::Result result = client.Get(
          "/something",
          httplib::Params({
            {"some-parameter", "178"}
        }),
        {}); // or `httplib::Headers{}`
}

The problem of the old behavior is that cpp-httplib server incorrectly allowed an invalid entry (no key, and no value). But the new behavior now reject such incorrect entries.

Please let me know if my understanding isn't correct.

@yhirose yhirose closed this as completed Sep 7, 2024
@Spixmaster
Copy link
Author

It works! Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants