HTTPSClient.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef HTTPSCLIENT_H
  2. #define HTTPSCLIENT_H
  3. #include "Socket/Socket.h"
  4. #include "Socket/Endpoint.h"
  5. #include "axTLS/ssl/ssl.h"
  6. #include "HTTPHeader.h"
  7. /**
  8. TCP socket connection
  9. */
  10. class HTTPSClient : public Socket, public Endpoint {
  11. public:
  12. /** TCP socket connection
  13. */
  14. HTTPSClient();
  15. virtual ~HTTPSClient();
  16. /** Connects this TCP socket to the server
  17. \param host The host to connect to. It can either be an IP Address or a hostname that will be resolved with DNS.
  18. \param port The host's port to connect to.
  19. \return 0 on success, -1 on failure.
  20. */
  21. int connect(const char* host);
  22. /** Check if the socket is connected
  23. \return true if connected, false otherwise.
  24. */
  25. bool is_connected(void);
  26. // Returns the size of the body
  27. HTTPHeader get(char *path);
  28. int read(char *data, int len);
  29. void close();
  30. private:
  31. int send(char* data, int length);
  32. uint8_t read_line();
  33. HTTPHeader read_header();
  34. bool _is_connected;
  35. SSL_CTX _ssl_ctx;
  36. SSL _ssl;
  37. std::string _host;
  38. };
  39. #endif