From f492d8b03a6405d1b4b3db040d0aa83473e814e6 Mon Sep 17 00:00:00 2001
From: winlin <winlin@vip.126.com>
Date: Sun, 28 Aug 2022 13:18:20 +0800
Subject: [PATCH] HTTP: Support API with body, for RTC.

---
 trunk/conf/http.api.one.port.conf   | 38 ++++++++++++++++++++++
 trunk/conf/http.api.one.port2.conf  | 50 +++++++++++++++++++++++++++++
 trunk/src/app/srs_app_http_conn.cpp |  5 ---
 3 files changed, 88 insertions(+), 5 deletions(-)
 create mode 100644 trunk/conf/http.api.one.port.conf
 create mode 100644 trunk/conf/http.api.one.port2.conf

diff --git a/trunk/conf/http.api.one.port.conf b/trunk/conf/http.api.one.port.conf
new file mode 100644
index 000000000..5a51c5110
--- /dev/null
+++ b/trunk/conf/http.api.one.port.conf
@@ -0,0 +1,38 @@
+# main config for srs.
+# @see full.conf for detail config.
+
+listen              1935;
+max_connections     1000;
+daemon              off;
+srs_log_tank        console;
+http_api {
+    enabled         on;
+    listen          8080;
+}
+http_server {
+    enabled         on;
+    listen          8080;
+    dir             ./objs/nginx/html;
+}
+rtc_server {
+    enabled on;
+    listen 8000; # UDP port
+    # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#config-candidate
+    candidate $CANDIDATE;
+}
+vhost __defaultVhost__ {
+    hls {
+        enabled         on;
+    }
+    http_remux {
+        enabled     on;
+        mount       [vhost]/[app]/[stream].flv;
+    }
+    rtc {
+        enabled     on;
+        # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtmp-to-rtc
+        rtmp_to_rtc off;
+        # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtc-to-rtmp
+        rtc_to_rtmp off;
+    }
+}
diff --git a/trunk/conf/http.api.one.port2.conf b/trunk/conf/http.api.one.port2.conf
new file mode 100644
index 000000000..a591c8705
--- /dev/null
+++ b/trunk/conf/http.api.one.port2.conf
@@ -0,0 +1,50 @@
+# main config for srs.
+# @see full.conf for detail config.
+
+listen              1935;
+max_connections     1000;
+daemon              off;
+srs_log_tank        console;
+http_api {
+    enabled         on;
+    listen          8080;
+    https {
+        enabled on;
+        listen 8088;
+        key ./conf/server.key;
+        cert ./conf/server.crt;
+    }
+}
+http_server {
+    enabled         on;
+    listen          8080;
+    dir             ./objs/nginx/html;
+    https {
+        enabled on;
+        listen 8088;
+        key ./conf/server.key;
+        cert ./conf/server.crt;
+    }
+}
+rtc_server {
+    enabled on;
+    listen 8000; # UDP port
+    # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#config-candidate
+    candidate $CANDIDATE;
+}
+vhost __defaultVhost__ {
+    hls {
+        enabled         on;
+    }
+    http_remux {
+        enabled     on;
+        mount       [vhost]/[app]/[stream].flv;
+    }
+    rtc {
+        enabled     on;
+        # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtmp-to-rtc
+        rtmp_to_rtc off;
+        # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtc-to-rtmp
+        rtc_to_rtmp off;
+    }
+}
diff --git a/trunk/src/app/srs_app_http_conn.cpp b/trunk/src/app/srs_app_http_conn.cpp
index 8457afb91..5528d8902 100644
--- a/trunk/src/app/srs_app_http_conn.cpp
+++ b/trunk/src/app/srs_app_http_conn.cpp
@@ -389,11 +389,6 @@ srs_error_t SrsHttpxConn::on_http_message(ISrsHttpMessage* r, SrsHttpResponseWri
     // For each session, we use short-term HTTP connection.
     SrsHttpHeader* hdr = w->header();
     hdr->set("Connection", "Close");
-
-    // Not support HTTP request with body.
-    if (r->content_length() > 0) {
-        return srs_error_new(ERROR_HTTP_WITH_BODY, "with %d body", r->content_length());
-    }
     
     return err;
 }