[Client] Parameters are not sent from >= v0.17.1
Spixmaster opened this issue · 3 comments
Spixmaster commented
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 commented
@Spixmaster thanks for the report. Could you give me more details? It seems like it is caused by #1908.
yhirose commented
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.
Spixmaster commented
It works! Thank you very much.