Re: [cgi-devel] HTTP_RAW_POST_DATA
Status: Beta
Brought to you by:
drrngrvy
From: <jc...@ol...> - 2011-04-14 14:34:59
|
Hello Darren Thanks for your answer. > The raw buffer is held in: > std::string& raw_post_data = req.post_buffer(); I am unable to get that information. Below is my sample program. With my browser I am getting "test" but if I use echo '<doc><item>Some content.</item></doc>' | curl -X POST -H 'Content-type: text/xml' -d @- http://example... I am getting nothing. the above bash command against a php script does show the raw_post_data/ Do you think the progam is right? I am using nginx with supervisord between the request and the fasctcgi app. Regards Jean-Christophe #include <fstream> #include <string> #include <iostream> #include <exception> #include <boost/cgi/fcgi.hpp> #include <boost/cgi/cgi.hpp> #include <boost/algorithm/string.hpp> template<typename Request, typename Response> int handle_request(Request& req, Response& resp) { try { req.clear(); resp.clear(); req.load(boost::fcgi::parse_all); resp << boost::fcgi::content_type("text/html;charset=ISO-8859-1"); resp << "test"; std::string& raw_post_data = req.post_buffer(); resp << raw_post_data; return commit(req, resp, 0); } catch(std::exception const & e ) { return commit(req, resp, 0); } return commit(req, resp, 0); } int main(int argc, char* argv[]) { int ret = 0; // the return value try { boost::fcgi::service s; boost::fcgi::acceptor a(s); for(;;) { boost::fcgi::request req(s); for (;;) { a.accept(req); boost::fcgi::response resp; ret = handle_request(req, resp); if (ret) { break; } } if (!a.is_open()) break; } } catch(boost::system::system_error const& err) { } catch(std::exception const& err) { } catch(...) { } std::cin.get(); return ret; } > Hi there, > > On 11 April 2011 18:42, <jc...@ol...> wrote: > >> Hello, >> >> I need to receive at an url like example.com/feedback an xml >> that could be sent with something like: >> echo '<doc><item>Some content.</item></doc>' | curl -X POST -H >> 'Content-type: text/xml' -d @- http://example.com/feedback >> >> in php, that xml string is captured by $HTTP_RAW_POST_DATA >> >> in my program, I do something like this for each request >> req.load(boost::fcgi::parse_all); >> but then I am unable to find the xml string >> How should I query req to get that xml? >> > > The raw buffer is held in: > > std::string& raw_post_data = req.post_buffer(); > > I've been using a similar pattern to this recently - ie. XML passed around > with the FastCGI protocol just being used as an efficient protocol... But, > the library lacks the client-side code to make it really useful in this > situation. It'd be good to support this type of use-case better. > > Suggestions in this area are most welcome. > > Cheers, > Darren > |