mbed-os

Fork of mbed-os by erkin yucel

Committer:
elessair
Date:
Sun Oct 23 15:10:02 2016 +0000
Revision:
0:f269e3021894
Initial commit

Who changed what in which revision?

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