diff mbox

[FFmpeg-devel,1/2] avformat/http: add ff_http_get_shutdown_status api for check the status of shutdown

Message ID 20190825145319.22263-1-lq@chinaffmpeg.org
State Superseded
Headers show

Commit Message

Liu Steven Aug. 25, 2019, 2:53 p.m. UTC
this function is used to get the previous shutdown status
when reusing the old connection in block mode.

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavformat/http.c | 16 ++++++++++++++++
 libavformat/http.h |  9 +++++++++
 2 files changed, 25 insertions(+)

Comments

Moritz Barsnick Aug. 26, 2019, 2:20 p.m. UTC | #1
On Sun, Aug 25, 2019 at 22:53:19 +0800, Steven Liu wrote:

Nitpicking:

> + * Get the HTTP shurdown reponse status, be used after http_shutdown.
                   ^        ^
Typos: shutdown, response.

Moritz
diff mbox

Patch

diff --git a/libavformat/http.c b/libavformat/http.c
index 579debcd35..71dd6c2b1f 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -304,6 +304,22 @@  fail:
         return location_changed;
     return ff_http_averror(s->http_code, AVERROR(EIO));
 }
+int ff_http_get_shutdown_status(URLContext *h)
+{
+    int ret = 0;
+    HTTPContext *s = h->priv_data;
+
+    /* flush the receive buffer when it is write only mode */
+    char buf[1024];
+    int read_ret;
+    read_ret = ffurl_read(s->hd, buf, sizeof(buf));
+    if (read_ret < 0) {
+        ret = read_ret;
+    }
+
+    return ret;
+}
+
 
 int ff_http_do_new_request(URLContext *h, const char *uri)
 {
diff --git a/libavformat/http.h b/libavformat/http.h
index 7d02713e31..a48897b0b8 100644
--- a/libavformat/http.h
+++ b/libavformat/http.h
@@ -37,6 +37,15 @@ 
  */
 void ff_http_init_auth_state(URLContext *dest, const URLContext *src);
 
+/**
+ * Get the HTTP shurdown reponse status, be used after http_shutdown.
+ *
+ * @param h pointer to the resource
+ * @return a negative value if an error condition occurred, 0
+ * otherwise
+ */
+int ff_http_get_shutdown_status(URLContext *h);
+
 /**
  * Send a new HTTP request, reusing the old connection.
  *