SUPPORT-8455. Реализован модуль подписания

This commit is contained in:
alashkova 2024-08-21 12:47:16 +03:00
commit 4243ebae5e
42 changed files with 4889 additions and 0 deletions

79
src/fcgisrv/fcgi_utils.c Normal file
View file

@ -0,0 +1,79 @@
#include "fcgi_server_internal.h"
#include "utils/logger.h"
#include <assert.h>
int
fcgi_get_content_length(const FCGX_Request* request)
{
int content_length = 0;
char* p = FCGX_GetParam(FCGI_PARAM_NAME_CONTENT_LENGTH, request->envp);
if (p != NULL) {
content_length = atoi(p);
}
return content_length;
}
char*
fcgi_request_get_param(const FCGX_Request* request, const char* name, /*out*/ bool* err)
{
assert(request != NULL);
assert(name != NULL);
assert(err != NULL);
char* param_value = FCGX_GetParam(name, request->envp);
if (param_value == NULL) {
LOG_ERROR("Could not get fcgi parameter '%s'", name);
goto error;
}
LOG_DEBUG("fcgi_request_get_param. name: %s, value: %s", name, param_value);
if (err) {
*err = false;
}
return param_value;
error:
LOG_ERROR("fcgi_request_get_param exit with error");
if (err) {
*err = true;
}
return NULL;
}
fcgi_handler_status_t
fcgi_printf_str(const FCGX_Request* request, const char* response, int response_len)
{
assert(request != NULL);
assert(response != NULL);
//int n = FCGX_FPrintF(request->out, response);
int n = FCGX_PutStr(response, response_len, request->out);
if (n < 0) {
LOG_ERROR("FCGX_PutStr failed");
return HANDLER_ERROR;
}
if (n != response_len) {
LOG_ERROR("response_len (%d) differs from the number of characters written (%d)",
response_len, n);
return HANDLER_ERROR;
}
return HANDLER_SUCCESS;
}
fcgi_handler_status_t
fcgi_printf_header(const FCGX_Request* request, const char* name, const char* value, int value_len)
{
if (FCGX_FPrintF(request->out, "%s: %.*s"CRLF, name, value_len, value) == -1) {
LOG_ERROR("FCGX_FPrintF failed");
return HANDLER_ERROR;
}
return HANDLER_SUCCESS;
}