ChipMaster's trial hacks on C++CMS starting with v1.2.1. Not sure I'll follow on with the v2 since it looks to be breaking and mostly frivolous.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

76 lines
2.5 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (C) 2008-2012 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
  4. //
  5. // See accompanying file COPYING.TXT file for licensing details.
  6. //
  7. ///////////////////////////////////////////////////////////////////////////////
  8. #ifndef CPPCMS_FORWARDER_H
  9. #define CPPCMS_FORWARDER_H
  10. #include <cppcms/defs.h>
  11. #include <booster/hold_ptr.h>
  12. #include <booster/shared_ptr.h>
  13. #include <booster/noncopyable.h>
  14. #include <booster/thread.h>
  15. #include <string>
  16. #include <map>
  17. namespace cppcms {
  18. class mount_point;
  19. namespace http {
  20. class context;
  21. }
  22. ///
  23. /// \brief Class responsble for automaticall forwarding of HTTP/CGI requests to other hosts over SCGI.
  24. ///
  25. /// This class allows you to strasfer connections transparently and efficiently for specific applications
  26. /// like single server responsible for Comet processing
  27. ///
  28. class CPPCMS_API forwarder {
  29. public:
  30. /// \cond INTERNAL
  31. forwarder();
  32. ~forwarder();
  33. typedef std::pair<std::string,int> address_type;
  34. address_type check_forwading_rules(std::string const &h,std::string const &s,std::string const &p);
  35. address_type check_forwading_rules(char const *h,char const *s,char const *p);
  36. /// \endcond
  37. ///
  38. /// Add forwarding of request that match a mount_point \a p over SCGI \a ip and \a port.
  39. ///
  40. void add_forwarding_rule(booster::shared_ptr<mount_point> p,std::string const &ip,int port);
  41. ///
  42. /// Remove the forwarding request, you need to use smake pointer you used in add_forwarding_rule
  43. ///
  44. void remove_forwarding_rule(booster::shared_ptr<mount_point> p);
  45. private:
  46. typedef std::map<booster::shared_ptr<mount_point> ,address_type> rules_type;
  47. rules_type rules_;
  48. booster::shared_mutex mutex_;
  49. struct _data;
  50. booster::hold_ptr<_data> d;
  51. };
  52. ///
  53. /// Forward the connection handled by \a cont to other node at IP \a ip listenning to on port \a port over
  54. /// SCGI protocol.
  55. ///
  56. /// The context must be released first by calling cppcms::application::release_context() and it should not
  57. /// be used after this function call.
  58. ///
  59. /// Please note: forwarding would not work for POST requests with multipart/form-data Content type as they
  60. /// are stored and managed differently.
  61. ///
  62. void CPPCMS_API forward_connection(booster::shared_ptr<http::context> cont,std::string const &ip,int port);
  63. }
  64. #endif