1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-11-03 04:17:17 -05:00

Fix: Only send 100 on request and 200 only on SOURCE

This commit is contained in:
Philipp Schafft 2019-05-14 08:29:20 +00:00
parent 0288af5a93
commit dbabf91510

View File

@ -836,7 +836,7 @@ static inline void source_startup(client_t *client)
refbuf_t *ok = refbuf_new(PER_CLIENT_REFBUF_SIZE); refbuf_t *ok = refbuf_new(PER_CLIENT_REFBUF_SIZE);
const char *expectcontinue; const char *expectcontinue;
const char *transfer_encoding; const char *transfer_encoding;
int status_to_send = 200; int status_to_send = 0;
ssize_t ret; ssize_t ret;
transfer_encoding = httpp_getvar(source->parser, "transfer-encoding"); transfer_encoding = httpp_getvar(source->parser, "transfer-encoding");
@ -848,25 +848,33 @@ static inline void source_startup(client_t *client)
} }
} }
/* For PUT support we check for 100-continue and send back a 100 to stay in spec */ if (source->parser && source->parser->req_type == httpp_req_source) {
expectcontinue = httpp_getvar (source->parser, "expect"); status_to_send = 200;
} else {
/* For PUT support we check for 100-continue and send back a 100 to stay in spec */
expectcontinue = httpp_getvar (source->parser, "expect");
if (expectcontinue != NULL) { if (expectcontinue != NULL) {
#ifdef HAVE_STRCASESTR #ifdef HAVE_STRCASESTR
if (strcasestr (expectcontinue, "100-continue") != NULL) if (strcasestr (expectcontinue, "100-continue") != NULL)
#else #else
ICECAST_LOG_WARN("OS doesn't support case insensitive substring checks..."); ICECAST_LOG_WARN("OS doesn't support case insensitive substring checks...");
if (strstr (expectcontinue, "100-continue") != NULL) if (strstr (expectcontinue, "100-continue") != NULL)
#endif #endif
{ {
status_to_send = 100; status_to_send = 100;
}
} }
} }
client->respcode = 200; client->respcode = 200;
ret = util_http_build_header(ok->data, PER_CLIENT_REFBUF_SIZE, 0, 0, status_to_send, NULL, NULL, NULL, NULL, NULL, client); if (status_to_send) {
snprintf(ok->data + ret, PER_CLIENT_REFBUF_SIZE - ret, "Content-Length: 0\r\n\r\n"); ret = util_http_build_header(ok->data, PER_CLIENT_REFBUF_SIZE, 0, 0, status_to_send, NULL, NULL, NULL, NULL, NULL, client);
ok->len = strlen(ok->data); snprintf(ok->data + ret, PER_CLIENT_REFBUF_SIZE - ret, "Content-Length: 0\r\n\r\n");
ok->len = strlen(ok->data);
} else {
ok->len = 0;
}
refbuf_release(client->refbuf); refbuf_release(client->refbuf);
client->refbuf = ok; client->refbuf = ok;
fserve_add_client_callback(client, source_client_callback, source); fserve_add_client_callback(client, source_client_callback, source);