|
|
|
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
|
|
|
/* Copyright 2022 Ivan Polyakov */
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \file request.h
|
|
|
|
* \brief Request.
|
|
|
|
*/
|
|
|
|
#ifndef RAPIDA_REQUEST_H_ENTRY
|
|
|
|
#define RAPIDA_REQUEST_H_ENTRY
|
|
|
|
|
|
|
|
#include "query.h"
|
|
|
|
#include "url.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Request method types.
|
|
|
|
*/
|
|
|
|
enum rpd_req_methods {
|
|
|
|
UNKNOWN = 0,
|
|
|
|
GET,
|
|
|
|
HEAD,
|
|
|
|
POST,
|
|
|
|
PUT,
|
|
|
|
DELETE,
|
|
|
|
CONNECT,
|
|
|
|
OPTIONS,
|
|
|
|
TRACE,
|
|
|
|
PATCH
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Request struct.
|
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
enum rpd_req_methods method; /**< Request method. */
|
|
|
|
char *body; /**< Body field. */
|
|
|
|
rpd_url path; /**< Requested URL. */
|
|
|
|
rpd_keyval headers; /**< Request headers. */
|
|
|
|
rpd_keyval query; /**< Query. */
|
|
|
|
rpd_keyval params; /**< Dynamic parameters. */
|
|
|
|
} rpd_req;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Fill request structure with initial values.
|
|
|
|
*
|
|
|
|
* \param dest Structure to fill.
|
|
|
|
*/
|
|
|
|
void rpd_req_init(rpd_req *dest);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Parse string request method to enumeration value.
|
|
|
|
*
|
|
|
|
* \param method Request method string.
|
|
|
|
*
|
|
|
|
* \return Request method.
|
|
|
|
*/
|
|
|
|
enum rpd_req_methods rpd_req_smethod(const char *method);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Clean request data.
|
|
|
|
*
|
|
|
|
* \param req Request instance.
|
|
|
|
*/
|
|
|
|
void rpd_req_cleanup(rpd_req *req);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Free request data memory.
|
|
|
|
*
|
|
|
|
* \param req Request instance.
|
|
|
|
*/
|
|
|
|
void rpd_req_free(rpd_req *req);
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* RAPIDA_REQUEST_H_ENTRY */
|