forked from Integreight/1Sheeld-Arduino-Library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HttpRequest.h
89 lines (78 loc) · 2.12 KB
/
HttpRequest.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
Project: 1Sheeld Library
File: HttpRequest.h
Version: 1.2
Compiler: Arduino avr-gcc 4.3.2
Author: Integreight
Date: 2015.1
*/
#ifndef HttpRequest_h
#define HttpRequest_h
//Output Function ID's for HTTP Request class
#define HTTP_REQUEST_URL 0x01
#define HTTP_SET_URL 0x02
#define HTTP_ADD_HEADER 0x03
#define HTTP_ADD_PARAMETER 0x04
#define HTTP_ADD_RAW_DATA 0x15
#define HTTP_DELETE_HEADER 0x05
#define HTTP_DELETE_PARAMETER 0x06
#define HTTP_SET_CONTENT_TYPE 0x07
#define HTTP_IGNORE_REQUEST 0x08
#define HTTP_SET_CONTENT_ENCODING 0x16
//Input Function ID's for HTTP Request class
#define HTTP_GET_SUCCESS 0x01
#define HTTP_GET_FAILURE 0x02
#define HTTP_GET_STARTED 0x03
#define HTTP_GET_ON_FINISH 0x05
#define SUCCESS_CALLBACK_BIT 0x01
#define FAILURE_CALLBACK_BIT 0x02
#define START_CALLBACK_BIT 0x04
#define FINISH_CALLBACK_BIT 0x08
class HttpRequest
{
public:
// #ifdef INTERNET_SHIELD
//Constructors
HttpRequest(const char *);
// #endif
//Setters
void setUrl(const char *);
//Adders
void addHeader(const char * ,const char *);
//Adders
void addParameter(const char * ,const char *);
void addRawData(const char *);
//Getters
int getId();
//Deleters
void deleteHeaders(void);
void deleteParameters(void);
void deleteCallBacks();
//Setters
void setContentType(const char * );
void setParametersContentEncoding(const char * );
//Deleter
void ignoreResponse(void);
//Set On for userFunctions
void setOnSuccess(void (*)(HttpResponse&));
void setOnFailure(void (*)(HttpResponse&));
void setOnStart(void (*)());
void setOnFinish(void (*)());
void sendInitFrame();
HttpResponse & getResponse();
~HttpRequest();
private:
bool isInitFrameSent;
char * url;
byte localRequestId[2];
void (*successCallBack)(HttpResponse &);
void (*failureCallBack)(HttpResponse &);
void (*startCallBack)();
void (*finishCallBack)();
byte callbacksRequested;
HttpResponse response;
static int totalRequests;
void sendInitFrame(const char *);
friend class InternetShield;
};
#endif