mirror of
https://github.com/polhenarejos/pico-keys-sdk
synced 2026-05-28 17:11:23 +02:00
Accept multiple HTTP methods.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
@@ -136,6 +136,10 @@ int rest_session_cleanup_expired(time_t expiration_time) {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rest_session_clear_all(void) {
|
||||||
|
memset(rest_sessions, 0, sizeof(rest_sessions));
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_APDU
|
#ifdef DEBUG_APDU
|
||||||
void rest_debug_dump_payload(const char *tag, const char *buffer, size_t len) {
|
void rest_debug_dump_payload(const char *tag, const char *buffer, size_t len) {
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|||||||
@@ -33,10 +33,22 @@
|
|||||||
#define REST_MAX_PATH_SIZE 192
|
#define REST_MAX_PATH_SIZE 192
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
REST_HTTP_GET = 0,
|
REST_HTTP_UNKNOWN = 0x0,
|
||||||
REST_HTTP_POST,
|
REST_HTTP_GET = 0x1,
|
||||||
REST_HTTP_PUT,
|
REST_HTTP_POST = 0x2,
|
||||||
REST_HTTP_DELETE
|
REST_HTTP_PUT = 0x4,
|
||||||
|
REST_HTTP_DELETE = 0x8,
|
||||||
|
REST_HTTP_GET_POST = REST_HTTP_GET | REST_HTTP_POST,
|
||||||
|
REST_HTTP_GET_PUT = REST_HTTP_GET | REST_HTTP_PUT,
|
||||||
|
REST_HTTP_GET_DELETE = REST_HTTP_GET | REST_HTTP_DELETE,
|
||||||
|
REST_HTTP_POST_PUT = REST_HTTP_POST | REST_HTTP_PUT,
|
||||||
|
REST_HTTP_POST_DELETE = REST_HTTP_POST | REST_HTTP_DELETE,
|
||||||
|
REST_HTTP_PUT_DELETE = REST_HTTP_PUT | REST_HTTP_DELETE,
|
||||||
|
REST_HTTP_GET_POST_PUT = REST_HTTP_GET | REST_HTTP_POST | REST_HTTP_PUT,
|
||||||
|
REST_HTTP_GET_POST_DELETE = REST_HTTP_GET | REST_HTTP_POST | REST_HTTP_DELETE,
|
||||||
|
REST_HTTP_GET_PUT_DELETE = REST_HTTP_GET | REST_HTTP_PUT | REST_HTTP_DELETE,
|
||||||
|
REST_HTTP_POST_PUT_DELETE = REST_HTTP_POST | REST_HTTP_PUT | REST_HTTP_DELETE,
|
||||||
|
REST_HTTP_GET_POST_PUT_DELETE = REST_HTTP_GET | REST_HTTP_POST | REST_HTTP_PUT | REST_HTTP_DELETE
|
||||||
} rest_http_method_t;
|
} rest_http_method_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@@ -129,6 +141,7 @@ extern int rest_session_update_activity(const uint8_t *id, size_t id_len);
|
|||||||
extern int rest_session_set_status(const uint8_t *id, size_t id_len, rest_session_status_t status);
|
extern int rest_session_set_status(const uint8_t *id, size_t id_len, rest_session_status_t status);
|
||||||
extern int rest_session_set_role(const uint8_t *id, size_t id_len, rest_session_role_t role);
|
extern int rest_session_set_role(const uint8_t *id, size_t id_len, rest_session_role_t role);
|
||||||
extern int rest_session_cleanup_expired(time_t expiration_time);
|
extern int rest_session_cleanup_expired(time_t expiration_time);
|
||||||
|
extern void rest_session_clear_all(void);
|
||||||
extern int rest_session_derive_key(const rest_session_t *session, uint8_t derived_key[32]);
|
extern int rest_session_derive_key(const rest_session_t *session, uint8_t derived_key[32]);
|
||||||
|
|
||||||
#ifdef DEBUG_APDU
|
#ifdef DEBUG_APDU
|
||||||
|
|||||||
@@ -698,7 +698,7 @@ void rest_handle_request(rest_conn_t *conn) {
|
|||||||
if (strcmp(routes[i].path, request->path) != 0) {
|
if (strcmp(routes[i].path, request->path) != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (routes[i].method != request->method) {
|
if (!(routes[i].method & request->method)) {
|
||||||
path_exists_for_other_method = true;
|
path_exists_for_other_method = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user