diff --git a/libavformat/http.c b/libavformat/http.c index 7cb65338ce..d5c02ddce0 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -49,13 +49,14 @@ typedef struct { HTTPAuthState auth_state; char *headers; int willclose; /**< Set if the server correctly handles Connection: close and will close the connection after feeding us the content. */ + int chunked_post; } HTTPContext; #define OFFSET(x) offsetof(HTTPContext, x) #define D AV_OPT_FLAG_DECODING_PARAM #define E AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { -{"chunksize", "use chunked transfer-encoding for posts, -1 disables it, 0 enables it", OFFSET(chunksize), AV_OPT_TYPE_INT64, {.dbl = 0}, -1, 0, E }, /* Default to 0, for chunked POSTs */ +{"chunked_post", "use chunked transfer-encoding for posts", OFFSET(chunked_post), AV_OPT_TYPE_INT, {.dbl = 1}, 0, 1, E }, {"headers", "custom HTTP headers, can override built in default headers", OFFSET(headers), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E }, {NULL} }; @@ -338,7 +339,7 @@ static int http_connect(URLContext *h, const char *path, const char *hoststr, "\r\n", post ? "POST" : "GET", path, - post && s->chunksize >= 0 ? "Transfer-Encoding: chunked\r\n" : "", + post && s->chunked_post ? "Transfer-Encoding: chunked\r\n" : "", headers, authstr ? authstr : ""); @@ -435,7 +436,7 @@ static int http_write(URLContext *h, const uint8_t *buf, int size) char crlf[] = "\r\n"; HTTPContext *s = h->priv_data; - if (s->chunksize == -1) { + if (!s->chunked_post) { /* non-chunked data is sent without any special encoding */ return ffurl_write(s->hd, buf, size); } @@ -461,7 +462,7 @@ static int http_close(URLContext *h) HTTPContext *s = h->priv_data; /* signal end of chunked encoding if used */ - if ((h->flags & AVIO_FLAG_WRITE) && s->chunksize != -1) { + if ((h->flags & AVIO_FLAG_WRITE) && s->chunked_post) { ret = ffurl_write(s->hd, footer, sizeof(footer) - 1); ret = ret > 0 ? 0 : ret; } diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 862582aaa8..8f7bd3718f 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -1486,7 +1486,7 @@ redirect: "Expires: Sun, 9 Jan 1972 00:00:00 GMT\r\n", sessioncookie); av_opt_set(rt->rtsp_hd_out->priv_data, "headers", headers, 0); - av_opt_set(rt->rtsp_hd_out->priv_data, "chunksize", "-1", 0); + av_opt_set(rt->rtsp_hd_out->priv_data, "chunked_post", "0", 0); /* Initialize the authentication state for the POST session. The HTTP * protocol implementation doesn't properly handle multi-pass