# Include "poco/NET/httpclientsession. H"
# Include "poco/NET/httprequest. H"
# Include "poco/NET/httpresponse. H"
# Include <poco/NET/httpcredentials. h>
# Include "poco/path. H"
# Include "poco/uri. H"
# Include "poco/NET/httpserver. H"
# Include "poco/NET/httprequesthandler. H"
# Include "poco/NET/httprequesthandlerfactory. H"
# Include "poco/NET/httpserverparams. H"
# Include "poco/NET/httpserverrequest. H"
# Include "poco/NET/httpserverresponse. H"
# Include "poco/NET/httpserverparams. H"
# Include "poco/NET/htmlform. H"
# Include "poco/NET/parthandler. H"
# Include "poco/NET/messageheader. H"
# Include "poco/NET/serversocket. H"
# Include "poco/countingstream. H"
# Include "poco/nullstream. H"
# Include "poco/streamcopier. H"
# Include "poco/exception. H"
# Include "poco/util/serverapplication. H"
# Include "poco/util/option. H"
# Include "poco/util/optionset. H"
# Include "poco/util/helpformatter. H"
# Include <iostream>
Using poco: Net: httpclientsession;
Using poco: Net: httprequest;
Using poco: Net: httpresponse;
Using poco: Net: httpmessage;
Using poco: streamcopier;
Using poco: path;
Using poco: URI;
Using poco: exception;
Int main (INT argc, char ** argv)
{
STD: vector <poco: Net: httpcookie> cookies;
STD: String struri = "http: // localhost/Hello/login ";
Poco: URI uri (struri );
STD: String path (URI. getpath ());
Poco: Net: httpclientsession SESSION (URI. gethost (), Uri. getport ());
Poco: Net: httprequest req (POCO: Net: httprequest: http_post, path, Poco: Net: httpmessage: http_1_1 );
Req. setcontenttype ("application/X-WWW-form-urlencoded ");
/*
If (! Cookies. Empty ())
{
Namevaluecollection NVC;
STD: vector For (; it! = Cookies. End (); ++ it)
NVC. Add (* It). getname (), (* It). getvalue ());
Req. setcookies (NVC );
}
*/
Poco: Net: htmlform form;
Form. Add ("username", "hello ");
Format. Add ("password", "123456 ");
// Send the request.
Form. preparesubmit (req );
STD: ostream & ostr = session. sendrequest (req );
Form. Write (ostr );
// Receive the response.
Poco: Net: httpresponse res;
STD: istream & rs = session. receiveresponse (RES );
STD: String responsetext;
Poco: streamcopier copier;
Copier. copytostring (RS, responsetext );
STD: cout <responsetext <STD: Endl;
Res. getcookies (cookies );
System ("pause ");
Return 0;
}