Overview
Features
Download
Documentation
Community
Add-Ons & Services

Make HTMLForm POST request

Please post support and help requests here.

Make HTMLForm POST request

Postby crashtua » 19 Aug 2012, 21:30

Hello. I dont know how to send HTMLForm POST request request. I have read that i must use
Code: Select all
HTMLForm(
    const HTTPRequest & request,
    std::istream & requestBody
);
constructor to create such form. But i dont know where to get this stream... Can some one give a short example, how to make proper POST requests?
crashtua
 
Posts: 8
Joined: 16 Aug 2012, 14:24

Re: Make HTMLForm POST request

Postby fbraem » 20 Aug 2012, 12:23

Use the HTMLForm() constructor and use the write method to send the form to the server ...
Zumuta!, that's the way to do IT!
fbraem
 
Posts: 102
Joined: 11 Aug 2008, 22:47
Location: Belgium

Re: Make HTMLForm POST request

Postby crashtua » 20 Aug 2012, 13:00

Cant understand why it is not working...
Clientside:
Code: Select all
HTTPClientSession session(uri.getHost(), uri.getPort());
HTTPRequest request(HTTPRequest::HTTP_POST, path, HTTPMessage::HTTP_1_1);
request.setChunkedTransferEncoding(true);
request.setContentType("application/x-www-form-urlencoded");
HTTPResponse response;
doRequest(session, request, response);
...
bool doRequest(Poco::Net::HTTPClientSession& session, Poco::Net::HTTPRequest& request, Poco::Net::HTTPResponse& response)
{
Poco::Net::HTMLForm params;
params.add("method","methodGet");
params.add("1","first arg");
params.write(session.sendRequest(request));
std::istream& rs = session.receiveResponse(response);
StreamCopier::copyStream(rs, std::cout);
if(response.getStatus() == HTTPResponse::HTTPStatus::HTTP_OK)
    return true;
else
    return false;
}

on serverside
Code: Select all
HTMLForm form(request);
int size = form.size();

but size is zero...
What i am doing wrong?
crashtua
 
Posts: 8
Joined: 16 Aug 2012, 14:24

Re: Make HTMLForm POST request

Postby crashtua » 20 Aug 2012, 13:38

I found that it is a server problem, Java server receive my request perfectly...
crashtua
 
Posts: 8
Joined: 16 Aug 2012, 14:24


Return to Support

Who is online

Users browsing this forum: No registered users and 1 guest