HttpPushSession.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include "Poco/Net/HTTPClientSession.h"
  3. #include "Poco/Net/HTTPSClientSession.h"
  4. #include "Poco/Net/HTTPRequest.h"
  5. #include "Poco/Net/HTTPResponse.h"
  6. #include "Poco/Net/Context.h"
  7. #include <istream>
  8. #include <ostream>
  9. #include "PhmsRequest.h"
  10. #include "PhmsResponse.h"
  11. #include "NetConfig.h"
  12. #include "PhmsDataType.h"
  13. using Poco::Net::HTTPClientSession;
  14. using Poco::Net::HTTPSClientSession;
  15. using Poco::Net::HTTPRequest;
  16. using Poco::Net::HTTPResponse;
  17. using Poco::Net::HTTPMessage;
  18. using Poco::Net::Context;
  19. class CHttpPushSession
  20. {
  21. public:
  22. CHttpPushSession(void);
  23. CHttpPushSession(bool bSsl);
  24. CHttpPushSession(CNetConfig netConfig);
  25. ~CHttpPushSession(void);
  26. private:
  27. bool m_bSsl;
  28. HTTPClientSession* m_pSession;
  29. Context::Ptr m_pContext;
  30. public:
  31. //Getter
  32. bool GetSsl();
  33. HTTPClientSession* GetHttpClientSession();
  34. int ExecuteHttpPushSession(CNetConfig& netConfig, CPhmsRequest& phmsRequest, pHttpPushCallback pCallback);
  35. int GetHttpExceptionInfo(int& nCode, string& msgName, string& msgText);
  36. int abort();
  37. private:
  38. int SetNetWork(CNetConfig& netConfig);
  39. int GenerateHttpRequest(CNetConfig& netConfig, CPhmsRequest& phmsRequest, string stringBoundary, HTTPRequest& httpRequest);
  40. int SendPhms(ostream& outputStream, string stringBoundary, CPhmsRequest& phmsRequest);
  41. int HandleHttpResponse(HTTPResponse& httpResponse);
  42. };