BBS2chProxyPoster.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #pragma once
  2. #include <string>
  3. #include <curl/curl.h>
  4. #include "BBS2chProxyConnection.h"
  5. #include "BBS2chProxyHttpHeaders.h"
  6. #include "BBS2chProxyFormData.h"
  7. #include "BBS2chProxyURL.h"
  8. class IBBS2chProxyPoster {
  9. protected:
  10. std::string _url;
  11. BBS2chProxyHttpHeaders &_requestHeaders;
  12. BBS2chProxyFormData &_requestBody;
  13. std::string _host;
  14. std::string _board;
  15. std::string _thread;
  16. std::string _nic;
  17. std::string _forceProxy;
  18. long _verbose;
  19. void prepareHeadersAndBody();
  20. curl_slist* prepareCurlHandle(BBS2chProxyHttpHeaders &headers, BBS2chProxyFormData &body, curl_slist* headersForCurl);
  21. void runLuaScript(BBS2chProxyHttpHeaders &headers, BBS2chProxyFormData &body);
  22. public:
  23. BBS2chProxyConnection *connectionDelegate;
  24. std::string _userAgentForRequest;
  25. std::string _monaKeyForRequest;
  26. bool _manageCookies;
  27. IBBS2chProxyPoster(BBS2chProxyHttpHeaders &headers, BBS2chProxyFormData &body, BBS2chProxyConnection *delegate);
  28. virtual ~IBBS2chProxyPoster() {};
  29. virtual long post() = 0;
  30. };
  31. class BBS2chProxy5chPoster : public IBBS2chProxyPoster {
  32. protected:
  33. void makeSignature(BBS2chProxyHttpHeaders &headers, BBS2chProxyFormData &body);
  34. public:
  35. bool _isFirstRun;
  36. int _status;
  37. bool _isResponseChunked;
  38. std::string _responseHeaders;
  39. bool _hasSetCookie;
  40. BBS2chProxy5chPoster(BBS2chProxyURL &url, BBS2chProxyHttpHeaders &headers, BBS2chProxyFormData &body, BBS2chProxyConnection *delegate);
  41. virtual ~BBS2chProxy5chPoster() {};
  42. virtual long post();
  43. };
  44. class BBS2chProxyTalkPoster : public IBBS2chProxyPoster {
  45. void makeSignature(BBS2chProxyHttpHeaders &headers, BBS2chProxyFormData &body);
  46. public:
  47. BBS2chProxyTalkPoster(BBS2chProxyURL &url, BBS2chProxyHttpHeaders &headers, BBS2chProxyFormData &body, BBS2chProxyConnection *delegate);
  48. virtual ~BBS2chProxyTalkPoster() {};
  49. virtual long post();
  50. };
  51. class BBS2chProxyTalkTo5chPoster : public BBS2chProxy5chPoster {
  52. public:
  53. BBS2chProxyTalkTo5chPoster(BBS2chProxyURL &url, BBS2chProxyHttpHeaders &headers, BBS2chProxyFormData &body, BBS2chProxyConnection *delegate);
  54. virtual ~BBS2chProxyTalkTo5chPoster() {};
  55. virtual long post();
  56. };