Commit 48f0c21d authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

https: revector initial response header handling

parent 69f16e15
...@@ -167,11 +167,10 @@ struct vlc_http_msg *vlc_http_mgr_reuse(struct vlc_http_mgr *mgr, ...@@ -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); struct vlc_http_stream *stream = vlc_http_stream_open(conn, req);
if (stream != NULL) 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) if (m != NULL)
return m; return m;
vlc_http_stream_close(stream, false);
/* NOTE: If the request were not idempotent, we would not know if it /* 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 * 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 * far, and CONNECT is treated as if it were idempotent (which works
......
...@@ -323,7 +323,7 @@ struct vlc_http_msg *vlc_http_mgr_request(struct vlc_http_mgr *mgr, bool https, ...@@ -323,7 +323,7 @@ struct vlc_http_msg *vlc_http_mgr_request(struct vlc_http_mgr *mgr, bool https,
assert(mtime == 1382386402); 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, int vlc_http_mgr_send_cookies(struct vlc_http_mgr *mgr,
......
...@@ -124,7 +124,8 @@ int main(void) ...@@ -124,7 +124,8 @@ int main(void)
assert(m == NULL); assert(m == NULL);
b = vlc_http_stream_read(s); b = vlc_http_stream_read(s);
assert(b == NULL); assert(b == NULL);
vlc_http_stream_close(s, true); m = vlc_http_msg_get_initial(s);
assert(m == NULL);
s = stream_open(); s = stream_open();
assert(s == NULL); assert(s == NULL);
...@@ -149,7 +150,7 @@ int main(void) ...@@ -149,7 +150,7 @@ int main(void)
s = stream_open(); s = stream_open();
assert(s != NULL); assert(s != NULL);
conn_send("HTTP/1.0 200 OK\r\n\r\n"); 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); assert(m != NULL);
conn_send("Hello world!"); conn_send("Hello world!");
...@@ -169,7 +170,7 @@ int main(void) ...@@ -169,7 +170,7 @@ int main(void)
s = stream_open(); s = stream_open();
assert(s != NULL); assert(s != NULL);
conn_send("HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n"); 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); assert(m != NULL);
conn_send("Hello again!"); conn_send("Hello again!");
...@@ -190,7 +191,7 @@ int main(void) ...@@ -190,7 +191,7 @@ int main(void)
assert(s != NULL); assert(s != NULL);
conn_send("HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n" conn_send("HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n"
"Content-Length: 1000000\r\n\r\n"); /* length must be ignored */ "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); assert(m != NULL);
conn_send("C\r\nHello there!\r\n0\r\n\r\n"); conn_send("C\r\nHello there!\r\n0\r\n\r\n");
...@@ -209,7 +210,7 @@ int main(void) ...@@ -209,7 +210,7 @@ int main(void)
s = stream_open(); s = stream_open();
assert(s != NULL); assert(s != NULL);
conn_send("HTTP/1.1 200 OK\r\nContent-Length: 8\r\n\r\n"); 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); assert(m != NULL);
conn_send("Bye bye!"); conn_send("Bye bye!");
......
...@@ -188,7 +188,7 @@ int main(void) ...@@ -188,7 +188,7 @@ int main(void)
s = stream_open(); s = stream_open();
assert(s != NULL); assert(s != NULL);
stream_reply(sid, false); stream_reply(sid, false);
m = vlc_http_stream_read_headers(s); m = vlc_http_msg_get_initial(s);
assert(m != NULL); assert(m != NULL);
vlc_http_msg_destroy(m); vlc_http_msg_destroy(m);
...@@ -205,7 +205,7 @@ int main(void) ...@@ -205,7 +205,7 @@ int main(void)
s = stream_open(); s = stream_open();
assert(s != NULL); assert(s != NULL);
stream_continuation(sid); stream_continuation(sid);
m = vlc_http_stream_read_headers(s); m = vlc_http_msg_get_initial(s);
assert(m != NULL); assert(m != NULL);
assert(vlc_http_msg_get_status(m) == 100); assert(vlc_http_msg_get_status(m) == 100);
stream_reply(sid, false); stream_reply(sid, false);
...@@ -238,10 +238,10 @@ int main(void) ...@@ -238,10 +238,10 @@ int main(void)
s2 = stream_open(); /* second stream to enforce test timing/ordering */ s2 = stream_open(); /* second stream to enforce test timing/ordering */
assert(s2 != NULL); assert(s2 != NULL);
stream_reply(sid, true); stream_reply(sid, true);
m = vlc_http_stream_read_headers(s2); m = vlc_http_msg_get_initial(s2);
assert(m != NULL); assert(m != NULL);
vlc_http_msg_destroy(m); vlc_http_msg_destroy(m);
m = vlc_http_stream_read_headers(s); m = vlc_http_msg_get_initial(s);
assert(m != NULL); assert(m != NULL);
assert(vlc_http_msg_get_status(m) == 200); assert(vlc_http_msg_get_status(m) == 200);
b = vlc_http_msg_read(m); b = vlc_http_msg_read(m);
...@@ -266,10 +266,10 @@ int main(void) ...@@ -266,10 +266,10 @@ int main(void)
stream_reply(sid, false); stream_reply(sid, false);
stream_reply(sid - 2, true); stream_reply(sid - 2, true);
stream_data(sid, "Discarded", false); /* not read data */ 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); assert(m != NULL);
vlc_http_msg_destroy(m); vlc_http_msg_destroy(m);
m = vlc_http_stream_read_headers(s2); m = vlc_http_msg_get_initial(s2);
assert(m != NULL); assert(m != NULL);
vlc_http_msg_destroy(m); vlc_http_msg_destroy(m);
......
...@@ -262,6 +262,14 @@ struct vlc_http_msg *vlc_http_msg_iterate(struct vlc_http_msg *m) ...@@ -262,6 +262,14 @@ struct vlc_http_msg *vlc_http_msg_iterate(struct vlc_http_msg *m)
return next; 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) 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) while (m != NULL && (vlc_http_msg_get_status(m) / 100) == 1)
......
...@@ -221,6 +221,8 @@ struct block_t *vlc_http_msg_read(struct vlc_http_msg *m) VLC_USED; ...@@ -221,6 +221,8 @@ struct block_t *vlc_http_msg_read(struct vlc_http_msg *m) VLC_USED;
struct vlc_http_stream; struct vlc_http_stream;
void vlc_http_msg_attach(struct vlc_http_msg *m, struct vlc_http_stream *s); 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 struct vlc_http_stream_cbs
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment