interceptor.h 887 B

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef CPR_INTERCEPTOR_H
  2. #define CPR_INTERCEPTOR_H
  3. #include "cpr/response.h"
  4. #include "cpr/session.h"
  5. namespace cpr {
  6. class Interceptor {
  7. public:
  8. enum class ProceedHttpMethod {
  9. GET_REQUEST = 0,
  10. POST_REQUEST,
  11. PUT_REQUEST,
  12. DELETE_REQUEST,
  13. PATCH_REQUEST,
  14. HEAD_REQUEST,
  15. OPTIONS_REQUEST,
  16. DOWNLOAD_CALLBACK_REQUEST,
  17. DOWNLOAD_FILE_REQUEST,
  18. };
  19. virtual ~Interceptor() = default;
  20. virtual Response intercept(Session& session) = 0;
  21. protected:
  22. static Response proceed(Session& session);
  23. static Response proceed(Session& session, ProceedHttpMethod httpMethod);
  24. static Response proceed(Session& session, ProceedHttpMethod httpMethod, std::ofstream& file);
  25. static Response proceed(Session& session, ProceedHttpMethod httpMethod, const WriteCallback& write);
  26. };
  27. } // namespace cpr
  28. #endif