LibJWT Dev
The C JSON Web Token Library +JWK +JWKS
|
These functions allow you to add, remove and retrieve headers from a JWT object. More...
Functions | |
const char * | jwt_get_header (jwt_t *jwt, const char *header) |
Return the value of a string header. | |
long | jwt_get_header_int (jwt_t *jwt, const char *header) |
Return the value of an integer header. | |
int | jwt_get_header_bool (jwt_t *jwt, const char *header) |
Return the value of an boolean header. | |
char * | jwt_get_headers_json (jwt_t *jwt, const char *header) |
Return the value of a header as JSON encoded object string. | |
int | jwt_add_header (jwt_t *jwt, const char *header, const char *val) |
Add a new string header to this JWT object. | |
int | jwt_add_header_int (jwt_t *jwt, const char *header, long val) |
Add a new integer header to this JWT object. | |
int | jwt_add_header_bool (jwt_t *jwt, const char *header, int val) |
Add a new boolean header to this JWT object. | |
int | jwt_add_headers_json (jwt_t *jwt, const char *json) |
Add headers from a JSON encoded object string. | |
int | jwt_del_headers (jwt_t *jwt, const char *header) |
Delete a header from this JWT object. | |
These functions allow you to add, remove and retrieve headers from a JWT object.
int jwt_add_header | ( | jwt_t * | jwt, |
const char * | header, | ||
const char * | val ) |
Add a new string header to this JWT object.
Creates a new header for this object. The string for header and val are copied internally, so do not require that the pointer or string remain valid for the lifetime of this object. It is an error if you try to add a header that already exists.
jwt | Pointer to a JWT object. |
header | String containing the name of the header to add. |
val | String containing the value to be saved for header. Can be an empty string, but cannot be NULL. |
int jwt_add_header_bool | ( | jwt_t * | jwt, |
const char * | header, | ||
int | val ) |
Add a new boolean header to this JWT object.
Creates a new header for this object. The string for header is copied internally, so do not require that the pointer or string remain valid for the lifetime of this object. It is an error if you try to add a header that already exists.
jwt | Pointer to a JWT object. |
header | String containing the name of the header to add. |
val | boolean containing the value to be saved for header. |
int jwt_add_header_int | ( | jwt_t * | jwt, |
const char * | header, | ||
long | val ) |
Add a new integer header to this JWT object.
Creates a new header for this object. The string for header is copied internally, so do not require that the pointer or string remain valid for the lifetime of this object. It is an error if you try to add a header that already exists.
jwt | Pointer to a JWT object. |
header | String containing the name of the header to add. |
val | int containing the value to be saved for header. |
int jwt_add_headers_json | ( | jwt_t * | jwt, |
const char * | json ) |
Add headers from a JSON encoded object string.
Loads a header from an existing JSON encoded object string. Overwrites existing header. If header is NULL, then the JSON encoded string is assumed to be a JSON hash of all headers being added and will be merged into the header listing.
jwt | Pointer to a JWT object. |
json | String containing a JSON encoded object of headers. |
int jwt_del_headers | ( | jwt_t * | jwt, |
const char * | header ) |
Delete a header from this JWT object.
Deletes the named header from this object. It is not an error if there is no header matching the passed name. If header is NULL, then all headers are deleted from this JWT.
jwt | Pointer to a JWT object. |
header | String containing the name of the header to delete. If this is NULL, then all headers are deleted. |
const char * jwt_get_header | ( | jwt_t * | jwt, |
const char * | header ) |
Return the value of a string header.
Returns the string value for a header (e.g. ""). If it does not exist, NULL will be returned.
jwt | Pointer to a JWT object. |
header | String containing the name of the header to return a value for. |
int jwt_get_header_bool | ( | jwt_t * | jwt, |
const char * | header ) |
Return the value of an boolean header.
Returns the int value for a header (e.g. ""). If it does not exist, 0 will be returned.
jwt | Pointer to a JWT object. |
header | String containing the name of the header to return a value for. |
long jwt_get_header_int | ( | jwt_t * | jwt, |
const char * | header ) |
Return the value of an integer header.
Returns the int value for a header (e.g. ""). If it does not exist, 0 will be returned.
jwt | Pointer to a JWT object. |
header | String containing the name of the header to return a value for. |
char * jwt_get_headers_json | ( | jwt_t * | jwt, |
const char * | header ) |
Return the value of a header as JSON encoded object string.
Returns the JSON encoded string value for a header (e.g. ""). If it does not exist, NULL will be returned.
jwt | Pointer to a JWT object. |
header | String containing the name of the header to return a value for. If this is NULL, all headers will be returned as a JSON encoded hash. |