forked from csquared/arduino-restclient
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathrest_client.h
64 lines (53 loc) · 1.6 KB
/
rest_client.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
******************************************************************************
* @file rest_client.h
*
* details: https://github.com/llad/spark-restclient
*
* credit: https://github.com/csquared/arduino-restclient
*
******************************************************************************
*/
#include "application.h"
class RestClient {
public:
RestClient(const char* host);
RestClient(const char* _host, int _port);
//Client Setup
void dhcp();
int begin(byte*);
//Generic HTTP Request
int request(const char* method, const char* path,
const char* body, String* response);
// Set a Request Header
void setHeader(const char*);
// GET path
int get(const char*);
// GET path and response
int get(const char*, String*);
// POST path and body
int post(const char* path, const char* body);
// POST path and body and response
int post(const char* path, const char* body, String*);
// PUT path and body
int put(const char* path, const char* body);
// PUT path and body and response
int put(const char* path, const char* body, String*);
// DELETE path
int del(const char*);
// DELETE path and body
int del(const char*, const char*);
// DELETE path and response
int del(const char*, String*);
// DELETE path and body and response
int del(const char*, const char*, String*);
private:
TCPClient client;
int readResponse(String*);
void write(const char*);
const char* host;
int port;
int num_headers;
const char* headers[10];
boolean contentTypeSet;
};