From ca0a703779667974cb8b371374174353f1bfba39 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Tue, 3 Mar 2015 16:03:23 +0100 Subject: [PATCH] http server: RTSP Session header cleanups, add more RTSP status codes --- src/http.c | 11 ++++++++--- src/http.h | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/http.c b/src/http.c index be0ac00f..eab13d04 100644 --- a/src/http.c +++ b/src/http.c @@ -221,6 +221,7 @@ http_send_header(http_connection_t *hc, int rc, const char *content, htsbuf_queue_t hdrs; http_arg_t *ra; time_t t; + int sess = 0; htsbuf_queue_init(&hdrs, 0); @@ -293,13 +294,16 @@ http_send_header(http_connection_t *hc, int rc, const char *content, if (++hc->hc_cseq == 0) hc->hc_cseq = 1; } - if(hc->hc_session) - htsbuf_qprintf(&hdrs, "Session: %s\r\n", hc->hc_session); if (args) { - TAILQ_FOREACH(ra, args, link) + TAILQ_FOREACH(ra, args, link) { + if (strcmp(ra->key, "Session") == 0) + sess = 1; htsbuf_qprintf(&hdrs, "%s: %s\r\n", ra->key, ra->val); + } } + if(hc->hc_session && !sess) + htsbuf_qprintf(&hdrs, "Session: %s\r\n", hc->hc_session); htsbuf_qprintf(&hdrs, "\r\n"); @@ -749,6 +753,7 @@ process_request(http_connection_t *hc, htsbuf_queue_t *spill) } free(hc->hc_representative); free(hc->hc_session); + hc->hc_session = NULL; return rval; } diff --git a/src/http.h b/src/http.h index 30ce1e5f..71ea02b0 100644 --- a/src/http.h +++ b/src/http.h @@ -76,6 +76,8 @@ typedef struct http_arg { #define HTTP_STATUS_EXPECTATION 418 #define HTTP_STATUS_BANDWIDTH 453 #define HTTP_STATUS_BAD_SESSION 454 +#define HTTP_STATUS_METHOD_INVALID 455 +#define HTTP_STATUS_BAD_TRANSFER 456 #define HTTP_STATUS_INTERNAL 500 #define HTTP_STATUS_NOT_IMPLEMENTED 501 #define HTTP_STATUS_BAD_GATEWAY 502