Thread: [Cppcms-users] Custom Headers in request()
Brought to you by:
artyom-beilis
From: Frank E. <fra...@an...> - 2010-11-28 15:37:04
|
hi, the cppcms::http::request class only provides access to predefined headers. now i try to implement CORS (http://www.w3.org/TR/cors/) in which case the browser sends 'Access-Control-Request-Method' and 'Access-Control-Request-Headers' headers whcih i cannot access using the existing methods (or am i mistaken?). would it be possible to make a method available which returns a map of all headers as sent by the browser? (something like std::map<std::string,std::string> cppcms::http::request::http_headers()) thanks frank -- Dipl.-Ing. (FH) Frank Enderle anamica UG (haftungsbeschränkt) Beinsteinerstr. 6 71334 Waiblingen Telefon: +49 151 14981091 Telefax: +49 7151 1335770 E-Mail: fra...@an... Internet: www.anamica.de Handelsregister: AG Stuttgart HRB 732357 Geschäftsführer: Yvonne Holzwarth, Frank Enderle |
From: Artyom <art...@ya...> - 2010-11-28 17:46:16
|
Hello, I think I answered this question ones. But anyway CppCMS uses CGI based API, in order to read some header like X-Foo-Bar you need to read environment variable HTTP_X_FOO_BAR (See [1]) However some web servers do not pass all headers for example nginx passes only headres defined explicitly in fastcgi configuration, so the behavior may vary between the servers. Cppcms has API for it cppcs::http::request::getenv() see [2]. So basically all you need is to call getenv() for CGI variable. [1] RFC3875 Common Gateway Interface v 1.1 Protocol-Specific Meta-Variables at http://www.ietf.org/rfc/rfc3875 [2] http://art-blog.no-ip.info/cppcms_ref_v0_99/classcppcms_1_1http_1_1request.html#e1027cdea2ba8a41a041269df8092ae3 and http://art-blog.no-ip.info/cppcms_ref_v0_99/classcppcms_1_1http_1_1request.html#92bc86f75e4e1f9480967ce3fd1e4f65 Artyom > hi, > > the cppcms::http::request class only provides access to predefined > headers. now i try to implement CORS (http://www.w3.org/TR/cors/) in > which case the browser sends 'Access-Control-Request-Method' and > 'Access-Control-Request-Headers' headers whcih i cannot access using the > existing methods (or am i mistaken?). > > would it be possible to make a method available which returns a map of > all headers as sent by the browser? (something like > std::map<std::string,std::string> cppcms::http::request::http_headers()) > > thanks > > frank |
From: Frank E. <fra...@an...> - 2010-11-29 09:40:14
|
Hi, thanks for pointing this out. Since the headers are not present in the environment I'll take a deeper look into nginx for filtering such headers. Frank Am 28.11.2010 18:46, schrieb Artyom: > Hello, > > I think I answered this question ones. But anyway > > CppCMS uses CGI based API, in order to read some > header like X-Foo-Bar you need to read environment > variable HTTP_X_FOO_BAR (See [1]) However > some web servers do not pass all headers for example > nginx passes only headres defined explicitly in fastcgi > configuration, so the behavior may vary between the servers. > > Cppcms has API for it cppcs::http::request::getenv() > see [2]. So basically all you need is to call getenv() > for CGI variable. > > [1] RFC3875 Common Gateway Interface v 1.1 Protocol-Specific > Meta-Variables at http://www.ietf.org/rfc/rfc3875 > > [2] > http://art-blog.no-ip.info/cppcms_ref_v0_99/classcppcms_1_1http_1_1request.html#e1027cdea2ba8a41a041269df8092ae3 > > and > http://art-blog.no-ip.info/cppcms_ref_v0_99/classcppcms_1_1http_1_1request.html#92bc86f75e4e1f9480967ce3fd1e4f65 > > > Artyom > > > >> hi, >> >> the cppcms::http::request class only provides access to predefined >> headers. now i try to implement CORS (http://www.w3.org/TR/cors/) in >> which case the browser sends 'Access-Control-Request-Method' and >> 'Access-Control-Request-Headers' headers whcih i cannot access using the >> existing methods (or am i mistaken?). >> >> would it be possible to make a method available which returns a map of >> all headers as sent by the browser? (something like >> std::map<std::string,std::string> cppcms::http::request::http_headers()) >> >> thanks >> >> frank > > > > > ------------------------------------------------------------------------------ > Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! > Tap into the largest installed PC base & get more eyes on your game by > optimizing for Intel(R) Graphics Technology. Get started today with the > Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. > http://p.sf.net/sfu/intelisp-dev2dev > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users -- Dipl.-Ing. (FH) Frank Enderle anamica UG (haftungsbeschränkt) Beinsteinerstr. 6 71334 Waiblingen Telefon: +49 151 14981091 Telefax: +49 7151 1335770 E-Mail: fra...@an... Internet: www.anamica.de Handelsregister: AG Stuttgart HRB 732357 Geschäftsführer: Yvonne Holzwarth, Frank Enderle |