Preliminary main mbed library for nexpaq development
libraries/net/https/HTTPSClient.h@0:6c56fb4bc5f0, 2016-11-04 (annotated)
- Committer:
- nexpaq
- Date:
- Fri Nov 04 20:27:58 2016 +0000
- Revision:
- 0:6c56fb4bc5f0
Moving to library for sharing updates
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nexpaq | 0:6c56fb4bc5f0 | 1 | #ifndef HTTPSCLIENT_H |
nexpaq | 0:6c56fb4bc5f0 | 2 | #define HTTPSCLIENT_H |
nexpaq | 0:6c56fb4bc5f0 | 3 | |
nexpaq | 0:6c56fb4bc5f0 | 4 | #include "Socket/Socket.h" |
nexpaq | 0:6c56fb4bc5f0 | 5 | #include "Socket/Endpoint.h" |
nexpaq | 0:6c56fb4bc5f0 | 6 | #include "axTLS/ssl/ssl.h" |
nexpaq | 0:6c56fb4bc5f0 | 7 | #include "HTTPHeader.h" |
nexpaq | 0:6c56fb4bc5f0 | 8 | |
nexpaq | 0:6c56fb4bc5f0 | 9 | /** |
nexpaq | 0:6c56fb4bc5f0 | 10 | TCP socket connection |
nexpaq | 0:6c56fb4bc5f0 | 11 | */ |
nexpaq | 0:6c56fb4bc5f0 | 12 | class HTTPSClient : public Socket, public Endpoint { |
nexpaq | 0:6c56fb4bc5f0 | 13 | |
nexpaq | 0:6c56fb4bc5f0 | 14 | public: |
nexpaq | 0:6c56fb4bc5f0 | 15 | /** TCP socket connection |
nexpaq | 0:6c56fb4bc5f0 | 16 | */ |
nexpaq | 0:6c56fb4bc5f0 | 17 | HTTPSClient(); |
nexpaq | 0:6c56fb4bc5f0 | 18 | |
nexpaq | 0:6c56fb4bc5f0 | 19 | |
nexpaq | 0:6c56fb4bc5f0 | 20 | virtual ~HTTPSClient(); |
nexpaq | 0:6c56fb4bc5f0 | 21 | |
nexpaq | 0:6c56fb4bc5f0 | 22 | /** Connects this TCP socket to the server |
nexpaq | 0:6c56fb4bc5f0 | 23 | \param host The host to connect to. It can either be an IP Address or a hostname that will be resolved with DNS. |
nexpaq | 0:6c56fb4bc5f0 | 24 | \param port The host's port to connect to. |
nexpaq | 0:6c56fb4bc5f0 | 25 | \return 0 on success, -1 on failure. |
nexpaq | 0:6c56fb4bc5f0 | 26 | */ |
nexpaq | 0:6c56fb4bc5f0 | 27 | int connect(const char* host); |
nexpaq | 0:6c56fb4bc5f0 | 28 | |
nexpaq | 0:6c56fb4bc5f0 | 29 | /** Check if the socket is connected |
nexpaq | 0:6c56fb4bc5f0 | 30 | \return true if connected, false otherwise. |
nexpaq | 0:6c56fb4bc5f0 | 31 | */ |
nexpaq | 0:6c56fb4bc5f0 | 32 | bool is_connected(void); |
nexpaq | 0:6c56fb4bc5f0 | 33 | |
nexpaq | 0:6c56fb4bc5f0 | 34 | // Returns the size of the body |
nexpaq | 0:6c56fb4bc5f0 | 35 | HTTPHeader get(char *path); |
nexpaq | 0:6c56fb4bc5f0 | 36 | |
nexpaq | 0:6c56fb4bc5f0 | 37 | int read(char *data, int len); |
nexpaq | 0:6c56fb4bc5f0 | 38 | |
nexpaq | 0:6c56fb4bc5f0 | 39 | |
nexpaq | 0:6c56fb4bc5f0 | 40 | void close(); |
nexpaq | 0:6c56fb4bc5f0 | 41 | |
nexpaq | 0:6c56fb4bc5f0 | 42 | private: |
nexpaq | 0:6c56fb4bc5f0 | 43 | |
nexpaq | 0:6c56fb4bc5f0 | 44 | |
nexpaq | 0:6c56fb4bc5f0 | 45 | int send(char* data, int length); |
nexpaq | 0:6c56fb4bc5f0 | 46 | |
nexpaq | 0:6c56fb4bc5f0 | 47 | uint8_t read_line(); |
nexpaq | 0:6c56fb4bc5f0 | 48 | HTTPHeader read_header(); |
nexpaq | 0:6c56fb4bc5f0 | 49 | |
nexpaq | 0:6c56fb4bc5f0 | 50 | bool _is_connected; |
nexpaq | 0:6c56fb4bc5f0 | 51 | SSL_CTX _ssl_ctx; |
nexpaq | 0:6c56fb4bc5f0 | 52 | SSL _ssl; |
nexpaq | 0:6c56fb4bc5f0 | 53 | std::string _host; |
nexpaq | 0:6c56fb4bc5f0 | 54 | }; |
nexpaq | 0:6c56fb4bc5f0 | 55 | |
nexpaq | 0:6c56fb4bc5f0 | 56 | #endif |