mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2025-04-18 00:48:43 -04:00
Update: Moved _update_client_request_body_length() into new client_complete()
This commit is contained in:
parent
c0155e2404
commit
c40d12a1c7
44
src/client.c
44
src/client.c
@ -103,6 +103,50 @@ int client_create(client_t **c_ptr, connection_t *con, http_parser_t *parser)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void client_complete(client_t *client)
|
||||||
|
{
|
||||||
|
const char *header;
|
||||||
|
long long unsigned int scannumber;
|
||||||
|
int have = 0;
|
||||||
|
|
||||||
|
if (!have) {
|
||||||
|
if (client->parser->req_type == httpp_req_source) {
|
||||||
|
client->request_body_length = -1; /* streaming */
|
||||||
|
have = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!have) {
|
||||||
|
header = httpp_getvar(client->parser, "transfer-encoding");
|
||||||
|
if (header) {
|
||||||
|
if (strcasecmp(header, "identity") != 0) {
|
||||||
|
client->request_body_length = -1; /* streaming */
|
||||||
|
have = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!have) {
|
||||||
|
header = httpp_getvar(client->parser, "content-length");
|
||||||
|
if (header) {
|
||||||
|
if (sscanf(header, "%llu", &scannumber) == 1) {
|
||||||
|
client->request_body_length = scannumber;
|
||||||
|
have = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!have) {
|
||||||
|
if (client->parser->req_type == httpp_req_put) {
|
||||||
|
/* As we don't know yet, we asume this PUT is in streaming mode */
|
||||||
|
client->request_body_length = -1; /* streaming */
|
||||||
|
have = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ICECAST_LOG_DEBUG("Client %p has request_body_length=%zi", client, client->request_body_length);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void client_reuseconnection(client_t *client) {
|
static inline void client_reuseconnection(client_t *client) {
|
||||||
connection_t *con;
|
connection_t *con;
|
||||||
reuse_t reuse;
|
reuse_t reuse;
|
||||||
|
@ -137,6 +137,7 @@ struct _client_tag {
|
|||||||
};
|
};
|
||||||
|
|
||||||
int client_create (client_t **c_ptr, connection_t *con, http_parser_t *parser);
|
int client_create (client_t **c_ptr, connection_t *con, http_parser_t *parser);
|
||||||
|
void client_complete(client_t *client);
|
||||||
void client_destroy(client_t *client);
|
void client_destroy(client_t *client);
|
||||||
void client_send_error_by_id(client_t *client, icecast_error_id_t id);
|
void client_send_error_by_id(client_t *client, icecast_error_id_t id);
|
||||||
void client_send_101(client_t *client, reuse_t reuse);
|
void client_send_101(client_t *client, reuse_t reuse);
|
||||||
|
@ -1429,50 +1429,6 @@ static void __prepare_shoutcast_admin_cgi_request(client_t *client)
|
|||||||
global_unlock();
|
global_unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _update_client_request_body_length(client_t *client)
|
|
||||||
{
|
|
||||||
const char *header;
|
|
||||||
long long unsigned int scannumber;
|
|
||||||
int have = 0;
|
|
||||||
|
|
||||||
if (!have) {
|
|
||||||
if (client->parser->req_type == httpp_req_source) {
|
|
||||||
client->request_body_length = -1; /* streaming */
|
|
||||||
have = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!have) {
|
|
||||||
header = httpp_getvar(client->parser, "transfer-encoding");
|
|
||||||
if (header) {
|
|
||||||
if (strcasecmp(header, "identity") != 0) {
|
|
||||||
client->request_body_length = -1; /* streaming */
|
|
||||||
have = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!have) {
|
|
||||||
header = httpp_getvar(client->parser, "content-length");
|
|
||||||
if (header) {
|
|
||||||
if (sscanf(header, "%llu", &scannumber) == 1) {
|
|
||||||
client->request_body_length = scannumber;
|
|
||||||
have = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!have) {
|
|
||||||
if (client->parser->req_type == httpp_req_put) {
|
|
||||||
/* As we don't know yet, we asume this PUT is in streaming mode */
|
|
||||||
client->request_body_length = -1; /* streaming */
|
|
||||||
have = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ICECAST_LOG_DEBUG("Client %p has request_body_length=%zi", client, client->request_body_length);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if we need body of client */
|
/* Check if we need body of client */
|
||||||
static int _need_body(client_queue_t *node)
|
static int _need_body(client_queue_t *node)
|
||||||
{
|
{
|
||||||
@ -1537,7 +1493,7 @@ static void _handle_connection(void)
|
|||||||
client->refbuf->len = 0;
|
client->refbuf->len = 0;
|
||||||
|
|
||||||
/* early check if we need more data */
|
/* early check if we need more data */
|
||||||
_update_client_request_body_length(client);
|
client_complete(client);
|
||||||
if (_need_body(node)) {
|
if (_need_body(node)) {
|
||||||
/* Just calling _add_body_client() would do the job.
|
/* Just calling _add_body_client() would do the job.
|
||||||
* However, if the client only has a small body this might work without moving it between queues.
|
* However, if the client only has a small body this might work without moving it between queues.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user