BBS2chProxyPoster.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. IBBS2chProxyPoster(BBS2chProxyHttpHeaders &headers, BBS2chProxyFormData &body, BBS2chProxyConnection *delegate);
  27. virtual ~IBBS2chProxyPoster() {};
  28. virtual long post() = 0;
  29. };
  30. class BBS2chProxy5chPoster : public IBBS2chProxyPoster {
  31. protected:
  32. void makeSignature(BBS2chProxyHttpHeaders &headers, BBS2chProxyFormData &body);
  33. public:
  34. bool _isFirstRun;
  35. int _status;
  36. bool _isResponseChunked;
  37. std::string _responseHeaders;
  38. BBS2chProxy5chPoster(BBS2chProxyURL &url, BBS2chProxyHttpHeaders &headers, BBS2chProxyFormData &body, BBS2chProxyConnection *delegate);
  39. virtual ~BBS2chProxy5chPoster() {};
  40. virtual long post();
  41. };
  42. class BBS2chProxyTalkPoster : public IBBS2chProxyPoster {
  43. void makeSignature(BBS2chProxyHttpHeaders &headers, BBS2chProxyFormData &body);
  44. public:
  45. BBS2chProxyTalkPoster(BBS2chProxyURL &url, BBS2chProxyHttpHeaders &headers, BBS2chProxyFormData &body, BBS2chProxyConnection *delegate);
  46. virtual ~BBS2chProxyTalkPoster() {};
  47. virtual long post();
  48. };
  49. class BBS2chProxyTalkTo5chPoster : public BBS2chProxy5chPoster {
  50. public:
  51. BBS2chProxyTalkTo5chPoster(BBS2chProxyURL &url, BBS2chProxyHttpHeaders &headers, BBS2chProxyFormData &body, BBS2chProxyConnection *delegate);
  52. virtual ~BBS2chProxyTalkTo5chPoster() {};
  53. virtual long post();
  54. };