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

https: add abort parameter to vlc_http_stream_close()

This is used to distinguish abortive stream termination from normal
clean termination. This is mostly useful for HTTP/1.
parent 51bd1874
...@@ -120,7 +120,7 @@ struct vlc_http_msg *vlc_https_request_reuse(struct vlc_http_mgr *mgr, ...@@ -120,7 +120,7 @@ struct vlc_http_msg *vlc_https_request_reuse(struct vlc_http_mgr *mgr,
if (m != NULL) if (m != NULL)
return m; return m;
vlc_http_stream_close(s); vlc_http_stream_close(s, false);
/* NOTE: If the request were not idempotent, NULL should be /* NOTE: If the request were not idempotent, NULL should be
* returned here. POST is not used/supported so far, and CONNECT is * returned here. POST is not used/supported so far, and CONNECT is
* treated as if it were idempotent (which turns out OK here). */ * treated as if it were idempotent (which turns out OK here). */
...@@ -141,7 +141,7 @@ struct vlc_http_msg *vlc_https_request_reuse(struct vlc_http_mgr *mgr, ...@@ -141,7 +141,7 @@ struct vlc_http_msg *vlc_https_request_reuse(struct vlc_http_mgr *mgr,
if (m != NULL) if (m != NULL)
return m; return m;
vlc_http_stream_close(s); vlc_http_stream_close(s, false);
} }
vlc_h1_conn_release(conn1); vlc_h1_conn_release(conn1);
#endif #endif
......
...@@ -191,9 +191,10 @@ static struct block_t *stream_read(struct vlc_http_stream *s) ...@@ -191,9 +191,10 @@ static struct block_t *stream_read(struct vlc_http_stream *s)
return NULL; return NULL;
} }
static void stream_close(struct vlc_http_stream *s) static void stream_close(struct vlc_http_stream *s, bool abort)
{ {
assert(s == &stream); assert(s == &stream);
assert(!abort);
} }
static const struct vlc_http_stream_cbs stream_callbacks = static const struct vlc_http_stream_cbs stream_callbacks =
......
...@@ -304,7 +304,7 @@ static block_t *vlc_h2_stream_read(struct vlc_http_stream *stream) ...@@ -304,7 +304,7 @@ static block_t *vlc_h2_stream_read(struct vlc_http_stream *stream)
* Sends an HTTP/2 stream reset, removes the stream from the HTTP/2 connection * Sends an HTTP/2 stream reset, removes the stream from the HTTP/2 connection
* and deletes any stream resource. * and deletes any stream resource.
*/ */
static void vlc_h2_stream_close(struct vlc_http_stream *stream) static void vlc_h2_stream_close(struct vlc_http_stream *stream, bool abort)
{ {
struct vlc_h2_stream *s = (struct vlc_h2_stream *)stream; struct vlc_h2_stream *s = (struct vlc_h2_stream *)stream;
struct vlc_h2_conn *conn = s->conn; struct vlc_h2_conn *conn = s->conn;
...@@ -323,7 +323,7 @@ static void vlc_h2_stream_close(struct vlc_http_stream *stream) ...@@ -323,7 +323,7 @@ static void vlc_h2_stream_close(struct vlc_http_stream *stream)
} }
vlc_mutex_unlock(&conn->lock); vlc_mutex_unlock(&conn->lock);
vlc_h2_stream_error(conn, s->id, VLC_H2_NO_ERROR); vlc_h2_stream_error(conn, s->id, abort ? VLC_H2_CANCEL : VLC_H2_NO_ERROR);
if (s->recv_hdr != NULL) if (s->recv_hdr != NULL)
vlc_http_msg_destroy(s->recv_hdr); vlc_http_msg_destroy(s->recv_hdr);
......
...@@ -156,7 +156,7 @@ int main(void) ...@@ -156,7 +156,7 @@ 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); vlc_http_stream_close(s, false);
/* Test accepted stream */ /* Test accepted stream */
sid += 2; sid += 2;
...@@ -245,7 +245,7 @@ int main(void) ...@@ -245,7 +245,7 @@ int main(void)
/* Test releasing connection before stream */ /* Test releasing connection before stream */
conn_destroy(); conn_destroy();
vlc_http_stream_close(s); vlc_http_stream_close(s, false);
return 0; return 0;
} }
...@@ -139,7 +139,7 @@ const char *vlc_http_msg_get_path(const struct vlc_http_msg *m) ...@@ -139,7 +139,7 @@ const char *vlc_http_msg_get_path(const struct vlc_http_msg *m)
void vlc_http_msg_destroy(struct vlc_http_msg *m) void vlc_http_msg_destroy(struct vlc_http_msg *m)
{ {
if (m->payload != NULL) if (m->payload != NULL)
vlc_http_stream_close(m->payload); vlc_http_stream_close(m->payload, false);
for (unsigned i = 0; i < m->count; i++) for (unsigned i = 0; i < m->count; i++)
{ {
......
...@@ -200,7 +200,7 @@ struct vlc_http_stream_cbs ...@@ -200,7 +200,7 @@ struct vlc_http_stream_cbs
{ {
struct vlc_http_msg *(*read_headers)(struct vlc_http_stream *); struct vlc_http_msg *(*read_headers)(struct vlc_http_stream *);
struct block_t *(*read)(struct vlc_http_stream *); struct block_t *(*read)(struct vlc_http_stream *);
void (*close)(struct vlc_http_stream *); void (*close)(struct vlc_http_stream *, bool abort);
}; };
struct vlc_http_stream struct vlc_http_stream
...@@ -219,9 +219,9 @@ static inline struct block_t *vlc_http_stream_read(struct vlc_http_stream *s) ...@@ -219,9 +219,9 @@ static inline struct block_t *vlc_http_stream_read(struct vlc_http_stream *s)
return s->cbs->read(s); return s->cbs->read(s);
} }
static inline void vlc_http_stream_close(struct vlc_http_stream *s) static inline void vlc_http_stream_close(struct vlc_http_stream *s, bool abort)
{ {
s->cbs->close(s); s->cbs->close(s, abort);
} }
char *vlc_http_msg_format(const struct vlc_http_msg *m, size_t *) VLC_USED; char *vlc_http_msg_format(const struct vlc_http_msg *m, size_t *) VLC_USED;
......
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