aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-11-22 17:48:45 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-11-22 17:48:45 +0100
commit15b2ec57ccaee49e8ec6de93d0ad7055da282e4d (patch)
tree28f51a97013c69fa1b1e3e5559a0bb5cfe4ec4b1
parent1d19f1b196c70cf2bd17d486e833bfa257314ef0 (diff)
parentbe4edda6731a341d3fdeaa0e57753dc396790362 (diff)
downloadffmpeg-15b2ec57ccaee49e8ec6de93d0ad7055da282e4d.tar.gz
Merge commit 'be4edda6731a341d3fdeaa0e57753dc396790362'
* commit 'be4edda6731a341d3fdeaa0e57753dc396790362': http: Expose the content location via an AVOption Conflicts: libavformat/http.c libavformat/version.h Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavformat/http.c20
-rw-r--r--libavformat/version.h2
2 files changed, 16 insertions, 6 deletions
diff --git a/libavformat/http.c b/libavformat/http.c
index c05cf4eeaf..0619e2a06c 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -55,7 +55,7 @@ typedef struct {
int64_t off, filesize;
int icy_data_read; ///< how much data was read since last ICY metadata packet
int icy_metaint; ///< after how many bytes of read data a new metadata packet will be found
- char location[MAX_URL_SIZE];
+ char *location;
HTTPAuthState auth_state;
HTTPAuthState proxy_auth_state;
char *headers;
@@ -104,6 +104,7 @@ static const AVOption options[] = {
{"none", "No auth method set, autodetect", 0, AV_OPT_TYPE_CONST, {.i64 = HTTP_AUTH_NONE}, 0, 0, D|E, "auth_type" },
{"basic", "HTTP basic authentication", 0, AV_OPT_TYPE_CONST, {.i64 = HTTP_AUTH_BASIC}, 0, 0, D|E, "auth_type" },
{"send_expect_100", "Force sending an Expect: 100-continue header for POST", OFFSET(send_expect_100), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, E },
+{"location", "The actual location of the data received", OFFSET(location), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
{NULL}
};
#define HTTP_CLASS(flavor)\
@@ -236,7 +237,10 @@ int ff_http_do_new_request(URLContext *h, const char *uri)
s->off = 0;
s->icy_data_read = 0;
- av_strlcpy(s->location, uri, sizeof(s->location));
+ av_free(s->location);
+ s->location = av_strdup(uri);
+ if (!s->location)
+ return AVERROR(ENOMEM);
av_dict_copy(&options, s->chained_options, 0);
ret = http_open_cnx(h, &options);
@@ -256,7 +260,9 @@ static int http_open(URLContext *h, const char *uri, int flags,
h->is_streamed = 1;
s->filesize = -1;
- av_strlcpy(s->location, uri, sizeof(s->location));
+ s->location = av_strdup(uri);
+ if (!s->location)
+ return AVERROR(ENOMEM);
if (options)
av_dict_copy(&s->chained_options, *options, 0);
@@ -356,10 +362,14 @@ static int process_line(URLContext *h, char *line, int line_count,
while (av_isspace(*p))
p++;
if (!av_strcasecmp(tag, "Location")) {
- char redirected_location[MAX_URL_SIZE];
+ char redirected_location[MAX_URL_SIZE], *new_loc;
ff_make_absolute_url(redirected_location, sizeof(redirected_location),
s->location, p);
- av_strlcpy(s->location, redirected_location, sizeof(s->location));
+ new_loc = av_strdup(redirected_location);
+ if (!new_loc)
+ return AVERROR(ENOMEM);
+ av_free(s->location);
+ s->location = new_loc;
*new_location = 1;
} else if (!av_strcasecmp (tag, "Content-Length") && s->filesize == -1) {
s->filesize = strtoll(p, NULL, 10);
diff --git a/libavformat/version.h b/libavformat/version.h
index a27dce3aae..871cef794a 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -31,7 +31,7 @@
#define LIBAVFORMAT_VERSION_MAJOR 55
#define LIBAVFORMAT_VERSION_MINOR 21
-#define LIBAVFORMAT_VERSION_MICRO 100
+#define LIBAVFORMAT_VERSION_MICRO 101
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \