|
|
|
@ -28,11 +28,10 @@ current_sandbox_send_response()
|
|
|
|
|
struct vec_u8 *response = sandbox->response;
|
|
|
|
|
assert(response != NULL);
|
|
|
|
|
|
|
|
|
|
int rc;
|
|
|
|
|
ssize_t sent = 0;
|
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
|
|
/* Determine values to template into our HTTP response */
|
|
|
|
|
ssize_t response_body_size = response->length;
|
|
|
|
|
size_t response_body_size = response->length;
|
|
|
|
|
char * module_content_type = sandbox->module->response_content_type;
|
|
|
|
|
const char *content_type = strlen(module_content_type) > 0 ? module_content_type : "text/plain";
|
|
|
|
|
|
|
|
|
@ -40,21 +39,11 @@ current_sandbox_send_response()
|
|
|
|
|
uint64_t end_time = __getcycles();
|
|
|
|
|
sandbox->total_time = end_time - sandbox->timestamp_of.request_arrival;
|
|
|
|
|
|
|
|
|
|
/* Generate and send HTTP Response Headers */
|
|
|
|
|
ssize_t response_header_size = http_response_200_size(content_type, response_body_size);
|
|
|
|
|
char response_header_buffer[response_header_size + 1];
|
|
|
|
|
rc = http_header_200_build(response_header_buffer, content_type, response_body_size);
|
|
|
|
|
if (rc <= 0) {
|
|
|
|
|
perror("sprintf");
|
|
|
|
|
goto err;
|
|
|
|
|
}
|
|
|
|
|
client_socket_send(sandbox->client_socket_descriptor, response_header_buffer, response_header_size,
|
|
|
|
|
/* Send HTTP Response Header and Body */
|
|
|
|
|
http_header_200_write(sandbox->client_socket_descriptor, module_content_type, response_body_size);
|
|
|
|
|
client_socket_send(sandbox->client_socket_descriptor, (const char *)response->buffer, response_body_size,
|
|
|
|
|
current_sandbox_sleep);
|
|
|
|
|
|
|
|
|
|
/* Send HTTP Response Body */
|
|
|
|
|
client_socket_send(sandbox->client_socket_descriptor, (const char *)response->buffer,
|
|
|
|
|
response_body_size, current_sandbox_sleep);
|
|
|
|
|
|
|
|
|
|
http_total_increment_2xx();
|
|
|
|
|
rc = 0;
|
|
|
|
|
|
|
|
|
|