Commit cdd09669 authored by Philipp Schafft's avatar Philipp Schafft 🦁

Feature: Added some more useful client fast events

parent 08cf0c12
......@@ -393,6 +393,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);
}
......@@ -416,6 +418,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);
}
......@@ -446,6 +450,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);
}
......@@ -457,6 +463,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 */
......@@ -576,6 +586,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;
......@@ -604,6 +615,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);
}
......
......@@ -1277,6 +1277,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);
......@@ -1417,6 +1419,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