From 6c1aeb1809865e8d8fbd84f2bda1e3190f7fd4c7 Mon Sep 17 00:00:00 2001 From: Jacob Su Date: Wed, 29 May 2024 17:56:13 +0800 Subject: [PATCH] improve http response when err happens. 1. response 200 with code when rtc/v1 remote sdp parse error; 2. response 500 when no handled err. --- trunk/src/app/srs_app_rtc_api.cpp | 8 +++++++- trunk/src/protocol/srs_protocol_http_stack.cpp | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/trunk/src/app/srs_app_rtc_api.cpp b/trunk/src/app/srs_app_rtc_api.cpp index 46512d8517..bdb4fcff0a 100644 --- a/trunk/src/app/srs_app_rtc_api.cpp +++ b/trunk/src/app/srs_app_rtc_api.cpp @@ -645,7 +645,13 @@ srs_error_t SrsGoApiRtcWhip::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessa SrsRtcUserConfig ruc; if ((err = do_serve_http(w, r, &ruc)) != srs_success) { - return srs_error_wrap(err, "serve"); + if (srs_error_code(err) == ERROR_RTC_SDP_EXCHANGE) { + srs_warn("RTC error %s", srs_error_desc(err).c_str()); + srs_freep(err); + return srs_api_response_code(w, r, SRS_CONSTS_HTTP_BadRequest); + } else { + return srs_error_wrap(err, "serve"); + } } if (ruc.local_sdp_str_.empty()) { return srs_go_http_error(w, SRS_CONSTS_HTTP_InternalServerError); diff --git a/trunk/src/protocol/srs_protocol_http_stack.cpp b/trunk/src/protocol/srs_protocol_http_stack.cpp index 8b02a3175a..c387542032 100644 --- a/trunk/src/protocol/srs_protocol_http_stack.cpp +++ b/trunk/src/protocol/srs_protocol_http_stack.cpp @@ -765,7 +765,9 @@ srs_error_t SrsHttpServeMux::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessa srs_assert(h); if ((err = h->serve_http(w, r)) != srs_success) { - return srs_error_wrap(err, "serve http"); + srs_error("serve_http %s", srs_error_desc(err).c_str()); + srs_freep(err); + return srs_go_http_error(w, SRS_CONSTS_HTTP_InternalServerError); } return err;