-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathRestClient.h
43 lines (35 loc) · 991 Bytes
/
RestClient.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <Arduino.h>
#include "Client.h"
class RestClient {
public:
RestClient(Client& netClient, const char* _host);
RestClient(Client& netClient, const char* _host, int _port);
//Generic HTTP Request
int request(const char* method, String path, String body);
// Set a Request Header
void setHeader(String header);
// Set Content-Type Header
void setContentType(String contentTypeValue);
// GET path
int get(String path);
// POST path and body
int post(String path, String body);
// PUT path and body
int put(String path, String body);
// DELETE path
int del(String path);
// DELETE path and body
int del(String path, String body);
String readResponse() {return responseBody;};
private:
Client* client;
int getResponse();
const char* host;
int port;
int num_headers;
String headers[10];
String contentType;
String responseBody;
int timeout;
long requestStart;
};