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,
if (m != NULL)
return m;
vlc_http_stream_close(s);
vlc_http_stream_close(s, false);
/* NOTE: If the request were not idempotent, NULL should be
* returned here. POST is not used/supported so far, and CONNECT is
* 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,
if (m != NULL)
return m;
vlc_http_stream_close(s);
vlc_http_stream_close(s, false);
}
vlc_h1_conn_release(conn1);
#endif
......
......@@ -191,9 +191,10 @@ static struct block_t *stream_read(struct vlc_http_stream *s)
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(!abort);
}
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)
* Sends an HTTP/2 stream reset, removes the stream from the HTTP/2 connection
* 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_conn *conn = s->conn;
......@@ -323,7 +323,7 @@ static void vlc_h2_stream_close(struct vlc_http_stream *stream)
}
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)
vlc_http_msg_destroy(s->recv_hdr);
......
......@@ -156,7 +156,7 @@ int main(void)
assert(m == NULL);
b = vlc_http_stream_read(s);
assert(b == NULL);
vlc_http_stream_close(s);
vlc_http_stream_close(s, false);
/* Test accepted stream */
sid += 2;
......@@ -245,7 +245,7 @@ int main(void)
/* Test releasing connection before stream */
conn_destroy();
vlc_http_stream_close(s);
vlc_http_stream_close(s, false);
return 0;
}
......@@ -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)
{
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++)
{
......
......@@ -200,7 +200,7 @@ struct vlc_http_stream_cbs
{
struct vlc_http_msg *(*read_headers)(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
......@@ -219,9 +219,9 @@ static inline struct block_t *vlc_http_stream_read(struct vlc_http_stream *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;
......
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