[vlc-commits] https: revector initial response header handling

Rémi Denis-Courmont git at videolan.org
Tue Jan 5 17:11:18 CET 2016


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Jan  5 16:19:44 2016 +0200| [48f0c21d97736d48c95f986802ee6914ba0ffc0c] | committer: Rémi Denis-Courmont

https: revector initial response header handling

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=48f0c21d97736d48c95f986802ee6914ba0ffc0c
---

 modules/access/http/connmgr.c     |    3 +--
 modules/access/http/file_test.c   |    2 +-
 modules/access/http/h1conn_test.c |   11 ++++++-----
 modules/access/http/h2conn_test.c |   12 ++++++------
 modules/access/http/message.c     |    8 ++++++++
 modules/access/http/message.h     |    2 ++
 6 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/modules/access/http/connmgr.c b/modules/access/http/connmgr.c
index d0c0435..d21503a 100644
--- a/modules/access/http/connmgr.c
+++ b/modules/access/http/connmgr.c
@@ -167,11 +167,10 @@ struct vlc_http_msg *vlc_http_mgr_reuse(struct vlc_http_mgr *mgr,
     struct vlc_http_stream *stream = vlc_http_stream_open(conn, req);
     if (stream != NULL)
     {
-        struct vlc_http_msg *m = vlc_http_stream_read_headers(stream);
+        struct vlc_http_msg *m = vlc_http_msg_get_initial(stream);
         if (m != NULL)
             return m;
 
-        vlc_http_stream_close(stream, false);
         /* NOTE: If the request were not idempotent, we would not know if it
          * was processed by the other end. Thus POST is not used/supported so
          * far, and CONNECT is treated as if it were idempotent (which works
diff --git a/modules/access/http/file_test.c b/modules/access/http/file_test.c
index c1ed791..489ddb2 100644
--- a/modules/access/http/file_test.c
+++ b/modules/access/http/file_test.c
@@ -323,7 +323,7 @@ struct vlc_http_msg *vlc_http_mgr_request(struct vlc_http_mgr *mgr, bool https,
             assert(mtime == 1382386402);
     }
 
-    return vlc_http_stream_read_headers(&stream);
+    return vlc_http_msg_get_initial(&stream);
 }
 
 int vlc_http_mgr_send_cookies(struct vlc_http_mgr *mgr,
diff --git a/modules/access/http/h1conn_test.c b/modules/access/http/h1conn_test.c
index 61f164a..e9c1e80 100644
--- a/modules/access/http/h1conn_test.c
+++ b/modules/access/http/h1conn_test.c
@@ -124,7 +124,8 @@ int main(void)
     assert(m == NULL);
     b = vlc_http_stream_read(s);
     assert(b == NULL);
-    vlc_http_stream_close(s, true);
+    m = vlc_http_msg_get_initial(s);
+    assert(m == NULL);
 
     s = stream_open();
     assert(s == NULL);
@@ -149,7 +150,7 @@ int main(void)
     s = stream_open();
     assert(s != NULL);
     conn_send("HTTP/1.0 200 OK\r\n\r\n");
-    m = vlc_http_stream_read_headers(s);
+    m = vlc_http_msg_get_initial(s);
     assert(m != NULL);
 
     conn_send("Hello world!");
@@ -169,7 +170,7 @@ int main(void)
     s = stream_open();
     assert(s != NULL);
     conn_send("HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n");
-    m = vlc_http_stream_read_headers(s);
+    m = vlc_http_msg_get_initial(s);
     assert(m != NULL);
 
     conn_send("Hello again!");
@@ -190,7 +191,7 @@ int main(void)
     assert(s != NULL);
     conn_send("HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n"
               "Content-Length: 1000000\r\n\r\n"); /* length must be ignored */
-    m = vlc_http_stream_read_headers(s);
+    m = vlc_http_msg_get_initial(s);
     assert(m != NULL);
 
     conn_send("C\r\nHello there!\r\n0\r\n\r\n");
@@ -209,7 +210,7 @@ int main(void)
     s = stream_open();
     assert(s != NULL);
     conn_send("HTTP/1.1 200 OK\r\nContent-Length: 8\r\n\r\n");
-    m = vlc_http_stream_read_headers(s);
+    m = vlc_http_msg_get_initial(s);
     assert(m != NULL);
 
     conn_send("Bye bye!");
diff --git a/modules/access/http/h2conn_test.c b/modules/access/http/h2conn_test.c
index d09d397..4cce51c 100644
--- a/modules/access/http/h2conn_test.c
+++ b/modules/access/http/h2conn_test.c
@@ -188,7 +188,7 @@ int main(void)
     s = stream_open();
     assert(s != NULL);
     stream_reply(sid, false);
-    m = vlc_http_stream_read_headers(s);
+    m = vlc_http_msg_get_initial(s);
     assert(m != NULL);
     vlc_http_msg_destroy(m);
 
@@ -205,7 +205,7 @@ int main(void)
     s = stream_open();
     assert(s != NULL);
     stream_continuation(sid);
-    m = vlc_http_stream_read_headers(s);
+    m = vlc_http_msg_get_initial(s);
     assert(m != NULL);
     assert(vlc_http_msg_get_status(m) == 100);
     stream_reply(sid, false);
@@ -238,10 +238,10 @@ int main(void)
     s2 = stream_open(); /* second stream to enforce test timing/ordering */
     assert(s2 != NULL);
     stream_reply(sid, true);
-    m = vlc_http_stream_read_headers(s2);
+    m = vlc_http_msg_get_initial(s2);
     assert(m != NULL);
     vlc_http_msg_destroy(m);
-    m = vlc_http_stream_read_headers(s);
+    m = vlc_http_msg_get_initial(s);
     assert(m != NULL);
     assert(vlc_http_msg_get_status(m) == 200);
     b = vlc_http_msg_read(m);
@@ -266,10 +266,10 @@ int main(void)
     stream_reply(sid, false);
     stream_reply(sid - 2, true);
     stream_data(sid, "Discarded", false); /* not read data */
-    m = vlc_http_stream_read_headers(s);
+    m = vlc_http_msg_get_initial(s);
     assert(m != NULL);
     vlc_http_msg_destroy(m);
-    m = vlc_http_stream_read_headers(s2);
+    m = vlc_http_msg_get_initial(s2);
     assert(m != NULL);
     vlc_http_msg_destroy(m);
 
diff --git a/modules/access/http/message.c b/modules/access/http/message.c
index bd9f2b1..fb0693b 100644
--- a/modules/access/http/message.c
+++ b/modules/access/http/message.c
@@ -262,6 +262,14 @@ struct vlc_http_msg *vlc_http_msg_iterate(struct vlc_http_msg *m)
     return next;
 }
 
+struct vlc_http_msg *vlc_http_msg_get_initial(struct vlc_http_stream *s)
+{
+    struct vlc_http_msg *m = vlc_http_stream_read_headers(s);
+    if (m == NULL)
+        vlc_http_stream_close(s, false);
+    return m;
+}
+
 struct vlc_http_msg *vlc_http_msg_get_final(struct vlc_http_msg *m)
 {
     while (m != NULL && (vlc_http_msg_get_status(m) / 100) == 1)
diff --git a/modules/access/http/message.h b/modules/access/http/message.h
index ebfc8aa..10f3f47 100644
--- a/modules/access/http/message.h
+++ b/modules/access/http/message.h
@@ -221,6 +221,8 @@ struct block_t *vlc_http_msg_read(struct vlc_http_msg *m) VLC_USED;
 struct vlc_http_stream;
 
 void vlc_http_msg_attach(struct vlc_http_msg *m, struct vlc_http_stream *s);
+struct vlc_http_msg *vlc_http_msg_get_initial(struct vlc_http_stream *s)
+VLC_USED;
 
 struct vlc_http_stream_cbs
 {



More information about the vlc-commits mailing list