Commit 0c3da2df authored by Marvin Scholz's avatar Marvin Scholz

Cleanup: Simplify client_complete

Instead of using a "have" variable which makes it a bit confusing
to understand whats going on, use a do {} while (0) and break from it
instead.
parent 4b2d38fc
......@@ -124,50 +124,41 @@ void client_complete(client_t *client)
{
const char *header;
long long unsigned int scannumber;
int have = 0;
if (!have) {
do {
header = httpp_getvar(client->parser, "content-length");
if (header) {
if (sscanf(header, "%llu", &scannumber) == 1) {
client->request_body_length = scannumber;
have = 1;
break;
}
}
}
if (!have) {
if (client->parser->req_type == httpp_req_source) {
client->request_body_length = -1; /* streaming */
have = 1;
break;
}
}
if (!have) {
header = httpp_getvar(client->parser, "transfer-encoding");
if (header) {
if (strcasecmp(header, "identity") != 0) {
client->request_body_length = -1; /* streaming */
have = 1;
break;
}
}
}
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;
break;
}
}
if (!have) {
if (client->parser->req_type == httpp_req_none) {
/* We are a client. If the server did not tell us, we asume streaming. */
client->request_body_length = -1; /* streaming */
have = 1;
break;
}
}
} while (0);
ICECAST_LOG_DEBUG("Client %p has request_body_length=%zi", client, client->request_body_length);
}
......
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