aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2011-11-10 11:03:35 +0200
committerMartin Storsjö <martin@martin.st>2011-11-10 13:21:26 +0200
commit6149485f6c6c2e600987a2759d97c546d4cf5da0 (patch)
treeab03b1654a1bdf5c4cd33130b6ba0228d20b1380
parenta2519280601209cc7f492e8e010efbaf1e0d7429 (diff)
downloadffmpeg-6149485f6c6c2e600987a2759d97c546d4cf5da0.tar.gz
http: Change the chunksize AVOption into chunked_post
The chunksize internal variable has two different uses - for reading, it's the amount of data left of the current chunk (or -1 if the server doesn't send data in chunked mode), where it's only an internal state variable. For writing, it's used to decide whether to enable chunked encoding (by default), by using the value 0, or disable chunked encoding (value -1). This, while consistent, doesn't make much sense to expose as an AVOption. This splits the usage of the internal variable into two variables, chunksize which is used for reading (as before), and chunked_post which is the user-settable option, with the values 0 and 1, where 1 is default. Signed-off-by: Martin Storsjö <martin@martin.st>
-rw-r--r--libavformat/http.c9
-rw-r--r--libavformat/rtsp.c2
2 files changed, 6 insertions, 5 deletions
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