diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-10-14 00:37:01 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-10-14 00:37:01 +0200 |
commit | 6b1b63df85ffa020bb36ac8d444a83b755a1d86d (patch) | |
tree | 232b69289597b1021be4547208b9e3e48ad6b45b /libavformat | |
parent | 5dee3e8bb45d5f80f23a588a27e5d99caaa8f021 (diff) | |
parent | 71549a857b13edf4c4f95037de6ed5bb4c4bd4af (diff) | |
download | ffmpeg-streaming-6b1b63df85ffa020bb36ac8d444a83b755a1d86d.zip ffmpeg-streaming-6b1b63df85ffa020bb36ac8d444a83b755a1d86d.tar.gz |
Merge commit '71549a857b13edf4c4f95037de6ed5bb4c4bd4af'
* commit '71549a857b13edf4c4f95037de6ed5bb4c4bd4af':
http: Support auth method detection for POST
Conflicts:
libavformat/version.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/http.c | 18 | ||||
-rw-r--r-- | libavformat/version.h | 2 |
2 files changed, 18 insertions, 2 deletions
diff --git a/libavformat/http.c b/libavformat/http.c index c148550..f88d58f 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -79,6 +79,7 @@ typedef struct { uint8_t *inflate_buffer; #endif AVDictionary *chained_options; + int send_expect_100; } HTTPContext; #define OFFSET(x) offsetof(HTTPContext, x) @@ -101,6 +102,7 @@ static const AVOption options[] = { {"auth_type", "HTTP authentication type", OFFSET(auth_state.auth_type), AV_OPT_TYPE_INT, {.i64 = HTTP_AUTH_NONE}, HTTP_AUTH_NONE, HTTP_AUTH_BASIC, D|E, "auth_type" }, {"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, "auth_type" }, {NULL} }; #define HTTP_CLASS(flavor)\ @@ -583,6 +585,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path, int64_t off = s->off; int len = 0; const char *method; + int send_expect_100 = 0; /* send http header */ @@ -600,6 +603,16 @@ static int http_connect(URLContext *h, const char *path, const char *local_path, method); proxyauthstr = ff_http_auth_create_response(&s->proxy_auth_state, proxyauth, local_path, method); + if (post && !s->post_data) { + send_expect_100 = s->send_expect_100; + /* The user has supplied authentication but we don't know the auth type, + * send Expect: 100-continue to get the 401 response including the + * WWW-Authenticate header, or an 100 continue if no auth actually + * is needed. */ + if (auth && s->auth_state.auth_type == HTTP_AUTH_NONE && + s->http_code != 401) + send_expect_100 = 1; + } /* set default headers if needed */ if (!has_header(s->headers, "\r\nUser-Agent: ")) @@ -614,6 +627,9 @@ static int http_connect(URLContext *h, const char *path, const char *local_path, if (!has_header(s->headers, "\r\nRange: ") && !post && (s->off > 0 || s->seekable == -1)) len += av_strlcatf(headers + len, sizeof(headers) - len, "Range: bytes=%"PRId64"-\r\n", s->off); + if (send_expect_100 && !has_header(s->headers, "\r\nExpect: ")) + len += av_strlcatf(headers + len, sizeof(headers) - len, + "Expect: 100-continue\r\n"); if (!has_header(s->headers, "\r\nConnection: ")) { if (s->multiple_requests) { @@ -684,7 +700,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path, s->willclose = 0; s->end_chunked_post = 0; s->end_header = 0; - if (post && !s->post_data) { + if (post && !s->post_data && !send_expect_100) { /* Pretend that it did work. We didn't read any header yet, since * we've still to send the POST data, but the code calling this * function will check http_code after we return. */ diff --git a/libavformat/version.h b/libavformat/version.h index 74ee297..ff38e96 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -31,7 +31,7 @@ #define LIBAVFORMAT_VERSION_MAJOR 55 #define LIBAVFORMAT_VERSION_MINOR 19 -#define LIBAVFORMAT_VERSION_MICRO 101 +#define LIBAVFORMAT_VERSION_MICRO 102 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ |