Question

I am using the poco c++ libraries , especially the HTTPServer from poco and I am already able to receive GET requests. (i followed this tutorial from page 24+). But i cannot figure out how to handle POST request, in particular, how can i read the request body out from the POST request with poco? From the Documentation of the class HttpServerRequest i read that the method stream can be used for this:

virtual std::istream & stream() = 0;
Returns the input stream for reading the request body.

okay, in my code i want to call this method like:

 std::istream& istr = request.stream();

but i am getting the error:

error: passing 'const Poco::Net::HTTPServerRequest' as 'this' argument of 'virtual std::istream& Poco::Net::HTTPServerRequest::stream()' discards qualifiers

what's wrong with my method call here? Can anybody help? or provide an example?

kind regards

Était-ce utile?

La solution

I'm not sure, because you stripped out the relevant part of the code, but the problem seems to occur because your request-object is declared as const. HTTPServerRequest::stream() is not declared const and therefore you're not allowed to call this method from a const-object.

So check out the following: where do you call the method HTTPServerRequest::stream()? Where does the request-object come from in this place? Is it declared to be constant (e.g. passed as a const function parameter)? Does it have to be declared constant in this place?

Greetings

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top