mikroSDK Reference Manual
http_common.h
Go to the documentation of this file.
1
31#ifndef _HTTP_COMMON_H
32#define _HTTP_COMMON_H
33
34//Dependencies
35#include "core/net.h"
36
37//HTTP port number
38#define HTTP_PORT 80
39//HTTPS port number (HTTP over TLS)
40#define HTTPS_PORT 443
41
42//Test macros for HTTP status codes
43#define HTTP_STATUS_CODE_1YZ(code) ((code) >= 100 && (code) < 200)
44#define HTTP_STATUS_CODE_2YZ(code) ((code) >= 200 && (code) < 300)
45#define HTTP_STATUS_CODE_3YZ(code) ((code) >= 300 && (code) < 400)
46#define HTTP_STATUS_CODE_4YZ(code) ((code) >= 400 && (code) < 500)
47#define HTTP_STATUS_CODE_5YZ(code) ((code) >= 500 && (code) < 600)
48
49//C++ guard
50#ifdef __cplusplus
51extern "C" {
52#endif
53
54
59typedef enum
60{
61 HTTP_VERSION_0_9 = 0x0009,
62 HTTP_VERSION_1_0 = 0x0100,
63 HTTP_VERSION_1_1 = 0x0101
65
66
71typedef enum
72{
73 HTTP_AUTH_MODE_NONE = 0,
74 HTTP_AUTH_MODE_BASIC = 1,
75 HTTP_AUTH_MODE_DIGEST = 2
77
78
83typedef enum
84{
85 HTTP_AUTH_QOP_NONE = 0,
86 HTTP_AUTH_QOP_AUTH = 1,
87 HTTP_AUTH_QOP_AUTH_INT = 2
89
90
95typedef enum
96{
97 HTTP_FLAG_WAIT_ALL = 0x0800,
98 HTTP_FLAG_BREAK_CHAR = 0x1000,
99 HTTP_FLAG_BREAK_CRLF = 0x100A,
100 HTTP_FLAG_NO_DELAY = 0x4000,
101 HTTP_FLAG_DELAY = 0x8000
102} HttpFlags;
103
104
109typedef enum
110{
111 HTTP_REQ_STATE_INIT = 0,
112 HTTP_REQ_STATE_FORMAT_HEADER = 1,
113 HTTP_REQ_STATE_SEND_HEADER = 2,
114 HTTP_REQ_STATE_FORMAT_BODY = 3,
115 HTTP_REQ_STATE_SEND_BODY = 4,
116 HTTP_REQ_STATE_SEND_CHUNK_SIZE = 5,
117 HTTP_REQ_STATE_SEND_CHUNK_DATA = 6,
118 HTTP_REQ_STATE_FORMAT_TRAILER = 7,
119 HTTP_REQ_STATE_SEND_TRAILER = 8,
120 HTTP_REQ_STATE_RECEIVE_STATUS_LINE = 9,
121 HTTP_REQ_STATE_RECEIVE_HEADER = 10,
122 HTTP_REQ_STATE_PARSE_HEADER = 11,
123 HTTP_REQ_STATE_RECEIVE_BODY = 12,
124 HTTP_REQ_STATE_RECEIVE_CHUNK_SIZE = 13,
125 HTTP_REQ_STATE_RECEIVE_CHUNK_DATA = 14,
126 HTTP_REQ_STATE_PARSE_BODY = 15,
127 HTTP_REQ_STATE_RECEIVE_TRAILER = 16,
128 HTTP_REQ_STATE_PARSE_TRAILER = 17,
129 HTTP_REQ_STATE_COMPLETE = 18
131
132
137typedef enum
138{
139 HTTP_CHARSET_OCTET = 0x0001,
140 HTTP_CHARSET_CTL = 0x0002,
141 HTTP_CHARSET_LWS = 0x0004,
142 HTTP_CHARSET_ALPHA = 0x0008,
143 HTTP_CHARSET_DIGIT = 0x0010,
144 HTTP_CHARSET_HEX = 0x0020,
145 HTTP_CHARSET_VCHAR = 0x0040,
146 HTTP_CHARSET_TCHAR = 0x0080,
147 HTTP_CHARSET_TEXT = 0x0100,
148 HTTP_CHARSET_OBS_TEXT = 0x0200
150
151
156typedef struct
157{
158 const char_t *name;
159 size_t nameLen;
160 const char_t *value;
161 size_t valueLen;
162} HttpParam;
163
164
165//HTTP related functions
166error_t httpCheckCharset(const char_t *s, size_t length, uint_t charset);
167
168error_t httpParseParam(const char_t **pos, HttpParam *param);
169bool_t httpCompareParamName(const HttpParam *param, const char_t *name);
170bool_t httpCompareParamValue(const HttpParam *param, const char_t *value);
171
172error_t httpCopyParamValue(const HttpParam *param, char_t *value,
173 size_t maxLen);
174
175void httpEncodeHexString(const uint8_t *input, size_t inputLen, char_t *output);
176
177//C++ guard
178#ifdef __cplusplus
179}
180#endif
181
182#endif
error_t
Error codes.
Definition error.h:43
HttpRequestState
HTTP request states.
Definition http_common.h:110
HttpFlags
Flags used by I/O functions.
Definition http_common.h:96
HttpCharset
HTTP character sets.
Definition http_common.h:138
HttpVersion
HTTP version numbers.
Definition http_common.h:60
HttpAuthMode
HTTP authentication schemes.
Definition http_common.h:72
HttpAuthQop
Quality of protection (digest authentication)
Definition http_common.h:84
TCP/IP stack core.
Attribute-value pair.
Definition http_common.h:157