I'm a new User of POCO and could get HTTP response after HTTP::Request.
By the way, How do I create HTTP request with some parameters? For example, I want to set URI, http://xxxx/index.html?name=hoge&id=fuga&data=foo.
Of course I know it's possible if I set this uri directly. But I want to realize this like below. Does anyone know this way?
URI uri("http://xxx/index.html");
uri.setParam("name", "hoge");
uri.setParam("id", "fuga");
uri.setParam("data", "foo");
If you had looked up the documentation for Poco::URI, you'd see it's done with uri.addQueryParameter("name", "value"):
void addQueryParameter( const std::string & param, const std::string & val = "" );Adds
"param=val"to the query;"param"may not be empty. Ifvalis empty, only'='is appended to the parameter.In addition to regular encoding, function also encodes
'&'and'=', if found inparamorval.
You can also set all the parameters with setQueryParameters.
Unfortunately, Poco doesn't let you set the value of an existing query parameter (or remove it). If you want to do that, you have to clear the query portion of the URI and readd all the parameters you want with their values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With