Commit 43c6271c by Philipp Schafft

Feature: Added some more useful client fast events

parent d0128776
Pipeline #241 passed with stage
in 47 seconds
......@@ -341,6 +341,8 @@ void client_send_101(client_t *client, reuse_t reuse)
client->respcode = 101;
client->refbuf->len = strlen(client->refbuf->data);
fastevent_emit(FASTEVENT_TYPE_CLIENT_SEND_RESPONSE, FASTEVENT_FLAG_MODIFICATION_ALLOWED, FASTEVENT_DATATYPE_CLIENT, client);
fserve_add_client(client, NULL);
}
......@@ -364,6 +366,8 @@ void client_send_204(client_t *client)
client->respcode = 204;
client->refbuf->len = strlen(client->refbuf->data);
fastevent_emit(FASTEVENT_TYPE_CLIENT_SEND_RESPONSE, FASTEVENT_FLAG_MODIFICATION_ALLOWED, FASTEVENT_DATATYPE_CLIENT, client);
fserve_add_client(client, NULL);
}
......@@ -394,6 +398,8 @@ void client_send_426(client_t *client, reuse_t reuse)
client->reuse = ICECAST_REUSE_KEEPALIVE;
fastevent_emit(FASTEVENT_TYPE_CLIENT_SEND_RESPONSE, FASTEVENT_FLAG_MODIFICATION_ALLOWED, FASTEVENT_DATATYPE_CLIENT, client);
fserve_add_client(client, NULL);
}
......@@ -405,6 +411,10 @@ static inline void client_send_500(client_t *client, const char *message)
const ssize_t header_len = sizeof(header) - 1;
ssize_t ret;
client->respcode = 500;
client->refbuf->len = 0;
fastevent_emit(FASTEVENT_TYPE_CLIENT_SEND_RESPONSE, FASTEVENT_FLAG_MODIFICATION_ALLOWED, FASTEVENT_DATATYPE_CLIENT, client);
ret = client_send_bytes(client, header, header_len);
/* only send message if we have one AND if header could have transmitted completly */
......@@ -524,6 +534,7 @@ void client_send_reportxml(client_t *client, reportxml_t *report, document_domai
client->refbuf->len = ret;
xmlFree(buff);
client->respcode = status;
fastevent_emit(FASTEVENT_TYPE_CLIENT_SEND_RESPONSE, FASTEVENT_FLAG_MODIFICATION_ALLOWED, FASTEVENT_DATATYPE_CLIENT, client);
fserve_add_client (client, NULL);
} else {
char *fullpath_xslt_template;
......@@ -552,6 +563,7 @@ void client_send_reportxml(client_t *client, reportxml_t *report, document_domai
config_release_config();
ICECAST_LOG_DEBUG("Sending XSLT (%s)", fullpath_xslt_template);
fastevent_emit(FASTEVENT_TYPE_CLIENT_SEND_RESPONSE, FASTEVENT_FLAG_MODIFICATION_ALLOWED, FASTEVENT_DATATYPE_CLIENT, client);
xslt_transform(doc, fullpath_xslt_template, client, status);
free(fullpath_xslt_template);
}
......
......@@ -1271,6 +1271,8 @@ static void _handle_authed_client(client_t *client, void *uri, auth_result resul
auth_stack_release(client->authstack);
client->authstack = NULL;
fastevent_emit(FASTEVENT_TYPE_CLIENT_AUTHED, FASTEVENT_FLAG_MODIFICATION_ALLOWED, FASTEVENT_DATATYPE_CLIENT, client);
if (result != AUTH_OK) {
client_send_error_by_id(client, ICECAST_ERROR_GEN_CLIENT_NEEDS_TO_AUTHENTICATE);
free(uri);
......@@ -1411,6 +1413,7 @@ static void _handle_authentication_mount_normal(client_t *client, char *uri)
static void _handle_authentication(client_t *client, char *uri)
{
fastevent_emit(FASTEVENT_TYPE_CLIENT_READY_FOR_AUTH, FASTEVENT_FLAG_MODIFICATION_ALLOWED, FASTEVENT_DATATYPE_CLIENT, client);
_handle_authentication_mount_normal(client, uri);
}
......
......@@ -29,6 +29,9 @@ typedef enum {
FASTEVENT_TYPE_CLIENT_READ,
FASTEVENT_TYPE_CLIENT_WRITE,
FASTEVENT_TYPE_CLIENT_READ_BODY,
FASTEVENT_TYPE_CLIENT_READY_FOR_AUTH,
FASTEVENT_TYPE_CLIENT_AUTHED,
FASTEVENT_TYPE_CLIENT_SEND_RESPONSE,
FASTEVENT_TYPE__END /* must be last element */
} fastevent_type_t;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment