---
libavformat/http.c | 28 ++++++++++++++++++++--------
1 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/libavformat/http.c b/libavformat/http.c
index 52e1886..3c9b2d0 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -47,13 +47,14 @@ typedef struct {
int64_t off, filesize;
char location[MAX_URL_SIZE];
HTTPAuthState auth_state;
- unsigned char headers[BUFFER_SIZE];
+ char *headers;
int willclose; /**< Set if the server correctly handles
Connection: close and will close the connection after feeding us the content. */
} HTTPContext;
#define OFFSET(x) offsetof(HTTPContext, x)
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 }, /* Default to 0, for chunked
POSTs */
+{"headers", "custom HTTP headers, can override built in default headers",
OFFSET(headers), AV_OPT_TYPE_STRING },
{NULL}
};
static const AVClass httpcontext_class = {
@@ -69,12 +70,9 @@ static int http_connect(URLContext *h, const char *path,
const char *hoststr,
void ff_http_set_headers(URLContext *h, const char *headers)
{
HTTPContext *s = h->priv_data;
- int len = strlen(headers);
- if (len && strcmp("\r\n", headers + len - 2))
- av_log(h, AV_LOG_ERROR, "No trailing CRLF found in HTTP header.\n");
-
- av_strlcpy(s->headers, headers, sizeof(s->headers));
+ av_freep(&s->headers);
+ s->headers = av_strdup(headers);
}
void ff_http_init_auth_state(URLContext *dest, const URLContext *src)
@@ -162,13 +160,23 @@ static int http_open_cnx(URLContext *h)
static int http_open(URLContext *h, const char *uri, int flags)
{
HTTPContext *s = h->priv_data;
+ int ret;
h->is_streamed = 1;
s->filesize = -1;
av_strlcpy(s->location, uri, sizeof(s->location));
- return http_open_cnx(h);
+ if (s->headers) {
+ int len = strlen(s->headers);
+ if (len < 2 || strcmp("\r\n", s->headers + len - 2))
+ av_log(h, AV_LOG_ERROR, "No trailing CRLF found in HTTP
header.\n");