mirror of
https://github.com/openappsec/attachment.git
synced 2026-01-17 16:00:26 +03:00
Adding base for async with kong
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "nano_attachment_sender_thread.h"
|
||||
#include "nano_attachment_sender_async.h"
|
||||
#include "nano_attachment_thread.h"
|
||||
#include "nano_utils.h"
|
||||
#include "nano_attachment_metric.h"
|
||||
@@ -317,7 +318,7 @@ HandleDelayedVerdict(
|
||||
sleep(attachment->hold_verdict_polling_time);
|
||||
write_dbg(attachment, session_id, DBG_LEVEL_DEBUG, "spawn SendDelayedVerdictRequestThread");
|
||||
res = NanoRunInThreadTimeout(
|
||||
attachment,
|
||||
attachment,
|
||||
data,
|
||||
SendDelayedVerdictRequestThread,
|
||||
(void *)ctx,
|
||||
@@ -783,6 +784,360 @@ SendResponseEnd(NanoAttachment *attachment, AttachmentData *data)
|
||||
return FinalizeSuccessfulResponse(attachment, session_id, &ctx);
|
||||
}
|
||||
|
||||
NanoCommunicationResult
|
||||
SendRequestFilterAsync(NanoAttachment *attachment, AttachmentData *data)
|
||||
{
|
||||
if (attachment == NULL || data == NULL) {
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
HttpSessionData *session_data_p = data->session_data;
|
||||
if (session_data_p == NULL) {
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
SessionID session_id = session_data_p->session_id;
|
||||
HttpRequestFilterData *start_data = (HttpRequestFilterData*)data->data;
|
||||
if (start_data == NULL) {
|
||||
write_dbg(
|
||||
attachment,
|
||||
session_id,
|
||||
DBG_LEVEL_WARNING,
|
||||
"NULL start_data in SendRequestFilterAsync for session ID: %d",
|
||||
session_id
|
||||
);
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
write_dbg(
|
||||
attachment,
|
||||
session_id,
|
||||
DBG_LEVEL_DEBUG,
|
||||
"Request filter handling session ID: %d",
|
||||
session_id
|
||||
);
|
||||
|
||||
if (handle_shmem_corruption(attachment) == NANO_ERROR) {
|
||||
write_dbg(
|
||||
attachment,
|
||||
session_id,
|
||||
DBG_LEVEL_WARNING,
|
||||
"Failed to handle shmem corruption in session ID: %d",
|
||||
session_id
|
||||
);
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
return SendRequestFilterAsyncImpl(attachment, session_data_p, start_data);
|
||||
}
|
||||
|
||||
NanoCommunicationResult
|
||||
SendMetadataAsync(NanoAttachment *attachment, AttachmentData *data)
|
||||
{
|
||||
if (attachment == NULL || data == NULL) {
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
HttpSessionData *session_data_p = data->session_data;
|
||||
if (session_data_p == NULL) {
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
SessionID session_id = session_data_p->session_id;
|
||||
HttpMetaData *metadata = (HttpMetaData*)data->data;
|
||||
if (metadata == NULL) {
|
||||
write_dbg(
|
||||
attachment,
|
||||
session_id,
|
||||
DBG_LEVEL_WARNING,
|
||||
"NULL metadata in SendMetadataAsync for session ID: %d",
|
||||
session_id
|
||||
);
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
write_dbg(
|
||||
attachment,
|
||||
session_id,
|
||||
DBG_LEVEL_DEBUG,
|
||||
"Metadata handling session ID: %d",
|
||||
session_id
|
||||
);
|
||||
|
||||
if (handle_shmem_corruption(attachment) == NANO_ERROR) {
|
||||
write_dbg(
|
||||
attachment,
|
||||
session_id,
|
||||
DBG_LEVEL_WARNING,
|
||||
"Failed to handle shmem corruption in session ID: %d",
|
||||
session_id
|
||||
);
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
return SendMetadataAsyncImpl(attachment, session_data_p, metadata);
|
||||
}
|
||||
|
||||
NanoCommunicationResult
|
||||
SendRequestHeadersAsync(NanoAttachment *attachment, AttachmentData *data)
|
||||
{
|
||||
if (attachment == NULL || data == NULL) {
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
HttpSessionData *session_data_p = data->session_data;
|
||||
if (session_data_p == NULL) {
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
SessionID session_id = session_data_p->session_id;
|
||||
HttpHeaders *headers = (HttpHeaders*)data->data;
|
||||
if (headers == NULL) {
|
||||
write_dbg(
|
||||
attachment,
|
||||
session_id,
|
||||
DBG_LEVEL_WARNING,
|
||||
"NULL headers in SendRequestHeadersAsync for session ID: %d",
|
||||
session_id
|
||||
);
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
write_dbg(
|
||||
attachment,
|
||||
session_id,
|
||||
DBG_LEVEL_DEBUG,
|
||||
"Request headers handling session ID: %d",
|
||||
session_id
|
||||
);
|
||||
|
||||
if (handle_shmem_corruption(attachment) == NANO_ERROR) {
|
||||
write_dbg(
|
||||
attachment,
|
||||
session_id,
|
||||
DBG_LEVEL_WARNING,
|
||||
"Failed to handle shmem corruption in session ID: %d",
|
||||
session_id
|
||||
);
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
return SendRequestHeadersAsyncImpl(attachment, session_data_p, headers);
|
||||
}
|
||||
|
||||
NanoCommunicationResult
|
||||
SendRequestBodyAsync(NanoAttachment *attachment, AttachmentData *data)
|
||||
{
|
||||
if (attachment == NULL || data == NULL) {
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
HttpSessionData *session_data_p = data->session_data;
|
||||
if (session_data_p == NULL) {
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
SessionID session_id = session_data_p->session_id;
|
||||
NanoHttpBody *bodies = (NanoHttpBody*)data->data;
|
||||
if (bodies == NULL) {
|
||||
write_dbg(
|
||||
attachment,
|
||||
session_id,
|
||||
DBG_LEVEL_WARNING,
|
||||
"NULL bodies in SendRequestBodyAsync for session ID: %d",
|
||||
session_id
|
||||
);
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
write_dbg(
|
||||
attachment,
|
||||
session_id,
|
||||
DBG_LEVEL_DEBUG,
|
||||
"Request body handling session ID: %d",
|
||||
session_id
|
||||
);
|
||||
|
||||
if (handle_shmem_corruption(attachment) == NANO_ERROR) {
|
||||
write_dbg(
|
||||
attachment,
|
||||
session_id,
|
||||
DBG_LEVEL_WARNING,
|
||||
"Failed to handle shmem corruption in session ID: %d",
|
||||
session_id
|
||||
);
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
return SendRequestBodyAsyncImpl(attachment, session_data_p, bodies);
|
||||
}
|
||||
|
||||
NanoCommunicationResult
|
||||
SendRequestEndAsync(NanoAttachment *attachment, AttachmentData *data)
|
||||
{
|
||||
if (attachment == NULL || data == NULL) {
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
HttpSessionData *session_data_p = data->session_data;
|
||||
if (session_data_p == NULL) {
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
SessionID session_id = session_data_p->session_id;
|
||||
|
||||
write_dbg(
|
||||
attachment,
|
||||
session_id,
|
||||
DBG_LEVEL_DEBUG,
|
||||
"Request end handling session ID: %d",
|
||||
session_id
|
||||
);
|
||||
|
||||
if (handle_shmem_corruption(attachment) == NANO_ERROR) {
|
||||
write_dbg(
|
||||
attachment,
|
||||
session_id,
|
||||
DBG_LEVEL_WARNING,
|
||||
"Failed to handle shmem corruption in session ID: %d",
|
||||
session_id
|
||||
);
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
return SendRequestEndAsyncImpl(attachment, session_data_p);
|
||||
}
|
||||
|
||||
NanoCommunicationResult
|
||||
SendResponseHeadersAsync(NanoAttachment *attachment, AttachmentData *data)
|
||||
{
|
||||
if (attachment == NULL || data == NULL) {
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
HttpSessionData *session_data_p = data->session_data;
|
||||
if (session_data_p == NULL) {
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
SessionID session_id = session_data_p->session_id;
|
||||
ResHttpHeaders *headers = (ResHttpHeaders*)data->data;
|
||||
if (headers == NULL) {
|
||||
write_dbg(
|
||||
attachment,
|
||||
session_id,
|
||||
DBG_LEVEL_WARNING,
|
||||
"NULL headers in SendResponseHeadersAsync for session ID: %d",
|
||||
session_id
|
||||
);
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
write_dbg(
|
||||
attachment,
|
||||
session_id,
|
||||
DBG_LEVEL_DEBUG,
|
||||
"Response headers handling session ID: %d",
|
||||
session_id
|
||||
);
|
||||
|
||||
if (handle_shmem_corruption(attachment) == NANO_ERROR) {
|
||||
write_dbg(
|
||||
attachment,
|
||||
session_id,
|
||||
DBG_LEVEL_WARNING,
|
||||
"Failed to handle shmem corruption in session ID: %d",
|
||||
session_id
|
||||
);
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
return SendResponseHeadersAsyncImpl(attachment, session_data_p, headers);
|
||||
}
|
||||
|
||||
NanoCommunicationResult
|
||||
SendResponseBodyAsync(NanoAttachment *attachment, AttachmentData *data)
|
||||
{
|
||||
if (attachment == NULL || data == NULL) {
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
HttpSessionData *session_data_p = data->session_data;
|
||||
if (session_data_p == NULL) {
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
SessionID session_id = session_data_p->session_id;
|
||||
NanoHttpBody *bodies = (NanoHttpBody*)data->data;
|
||||
if (bodies == NULL) {
|
||||
write_dbg(
|
||||
attachment,
|
||||
session_id,
|
||||
DBG_LEVEL_WARNING,
|
||||
"NULL bodies in SendResponseBodyAsync for session ID: %d",
|
||||
session_id
|
||||
);
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
write_dbg(
|
||||
attachment,
|
||||
session_id,
|
||||
DBG_LEVEL_DEBUG,
|
||||
"Response body handling session ID: %d",
|
||||
session_id
|
||||
);
|
||||
|
||||
if (handle_shmem_corruption(attachment) == NANO_ERROR) {
|
||||
write_dbg(
|
||||
attachment,
|
||||
session_id,
|
||||
DBG_LEVEL_WARNING,
|
||||
"Failed to handle shmem corruption in session ID: %d",
|
||||
session_id
|
||||
);
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
return SendResponseBodyAsyncImpl(attachment, session_data_p, bodies);
|
||||
}
|
||||
|
||||
NanoCommunicationResult
|
||||
SendResponseEndAsync(NanoAttachment *attachment, AttachmentData *data)
|
||||
{
|
||||
if (attachment == NULL || data == NULL) {
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
HttpSessionData *session_data_p = data->session_data;
|
||||
if (session_data_p == NULL) {
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
SessionID session_id = session_data_p->session_id;
|
||||
|
||||
write_dbg(
|
||||
attachment,
|
||||
session_id,
|
||||
DBG_LEVEL_DEBUG,
|
||||
"Response end handling session ID: %d",
|
||||
session_id
|
||||
);
|
||||
|
||||
if (handle_shmem_corruption(attachment) == NANO_ERROR) {
|
||||
write_dbg(
|
||||
attachment,
|
||||
session_id,
|
||||
DBG_LEVEL_WARNING,
|
||||
"Failed to handle shmem corruption in session ID: %d",
|
||||
session_id
|
||||
);
|
||||
return NANO_ERROR;
|
||||
}
|
||||
|
||||
return SendResponseEndAsyncImpl(attachment, session_data_p);
|
||||
}
|
||||
|
||||
NanoCommunicationResult
|
||||
SendMetricData(NanoAttachment *attachment)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user