From 29b9203428c33898237539acfc2ac3d90c6bd8b0 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 17 Mar 2020 12:10:42 +0800 Subject: [PATCH] For #1638, #307, use short-term http connection for rtc to use new cid. --- trunk/src/app/srs_app_http_api.cpp | 4 ++++ trunk/src/service/srs_service_http_conn.cpp | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/trunk/src/app/srs_app_http_api.cpp b/trunk/src/app/srs_app_http_api.cpp index cb8615d68..32ccf8e12 100644 --- a/trunk/src/app/srs_app_http_api.cpp +++ b/trunk/src/app/srs_app_http_api.cpp @@ -799,6 +799,10 @@ srs_error_t SrsGoApiSdp::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* // path: {pattern} // method: POST // e.g. /api/v1/sdp/ args = json:{"sdp":"sdp...", "app":"webrtc", "stream":"test"} + + // For each RTC session, we use short-term HTTP connection. + SrsHttpHeader* hdr = w->header(); + hdr->set("Connection", "Close"); string req_json; if ((err = r->body_read_all(req_json)) != srs_success) { diff --git a/trunk/src/service/srs_service_http_conn.cpp b/trunk/src/service/srs_service_http_conn.cpp index cff5b26a3..815fc8670 100644 --- a/trunk/src/service/srs_service_http_conn.cpp +++ b/trunk/src/service/srs_service_http_conn.cpp @@ -907,7 +907,9 @@ srs_error_t SrsHttpResponseWriter::send_header(char* data, int size) } // keep alive to make vlc happy. - hdr->set("Connection", "Keep-Alive"); + if (hdr->get("Connection").empty()) { + hdr->set("Connection", "Keep-Alive"); + } // Filter the header before writing it. if (hf && ((err = hf->filter(hdr)) != srs_success)) {