1- From afb9fa8e856b5f1fa0d1e5d67192567167507aeb Mon Sep 17 00:00:00 2001
1+ From 29b3f4f302406cc546d87e5e8d26a20417bfcb63 Mon Sep 17 00:00:00 2001
22From: qianlongxu <
[email protected] >
3- Date: Tue, 12 Nov 2024 14:40:18 +0800
4- Subject: [PATCH 23 ] fix http open and http_seek (redirect) authentication bug
3+ Date: Tue, 12 Nov 2024 16:00:23 +0800
4+ Subject: [PATCH] fix http open and http_seek (redirect) authentication bug
55
66---
7- libavformat/http.c | 25 +++++++++++++++++++++++- -
8- 1 file changed, 23 insertions(+), 2 deletions (-)
7+ libavformat/http.c | 25 ++++++++++++++++++++++++ -
8+ 1 file changed, 24 insertions(+), 1 deletion (-)
99
1010diff --git a/libavformat/http.c b/libavformat/http.c
11- index 06f1bdd..7c60a66 100644
11+ index 980bfde..f6c69c2 100644
1212--- a/libavformat/http.c
1313+++ b/libavformat/http.c
1414@@ -78,6 +78,7 @@ typedef struct HTTPContext {
@@ -27,27 +27,27 @@ index 06f1bdd..7c60a66 100644
2727 { "none", "No auth method set, autodetect", 0, AV_OPT_TYPE_CONST, { .i64 = HTTP_AUTH_NONE }, 0, 0, D | E, "auth_type"},
2828 { "basic", "HTTP basic authentication", 0, AV_OPT_TYPE_CONST, { .i64 = HTTP_AUTH_BASIC }, 0, 0, D | E, "auth_type"},
2929 { "send_expect_100", "Force sending an Expect: 100-continue header for POST", OFFSET(send_expect_100), AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, E },
30- @@ -699,7 +701,10 @@ static int http_open(URLContext *h, const char *uri, int flags,
31- HTTPContext *s = h->priv_data;
30+ @@ -700,6 +702,11 @@ static int http_open(URLContext *h, const char *uri, int flags,
3231 int ret;
3332 s->app_ctx = (AVApplicationContext *)av_dict_strtoptr(s->app_ctx_intptr);
34- -
33+
3534+ if (s->auth_type2 == HTTP_AUTH_NONE) {
3635+ //backup the init auth_type, when not assign.
3736+ s->auth_type2 = s->auth_state.auth_type;
3837+ }
39- // av_log(NULL, AV_LOG_INFO, "%-*s: %-*s = %s\n", 12, "xql http_open verify", 28, "ijkapplication", s->app_ctx_intptr);
40- // av_log(NULL, AV_LOG_INFO, "%-*s: %-*s = %s\n", 12, "xql http_open verify", 28, "tcp_hook", s->tcp_hook);
41-
42- @@ -1428,6 +1433,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
38+ +
39+ if( s->seekable == 1 )
40+ h->is_streamed = 0;
41+ else
42+ @@ -1425,6 +1432,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
4343 uint64_t off = s->off;
4444 const char *method;
4545 int send_expect_100 = 0;
4646+ int cur_auth_type = s->auth_state.auth_type;
4747
4848 av_bprint_init_for_buffer(&request, s->buffer, sizeof(s->buffer));
4949
50- @@ -1569 ,9 +1575 ,19 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
50+ @@ -1566 ,9 +1574 ,19 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
5151
5252 if (s->new_location)
5353 s->off = off;
@@ -68,7 +68,7 @@ index 06f1bdd..7c60a66 100644
6868 av_freep(&authstr);
6969 av_freep(&proxyauthstr);
7070 return err;
71- @@ -1961 ,6 +1977 ,8 @@ static int64_t http_seek_internal(URLContext *h, int64_t off, int whence, int fo
71+ @@ -1958 ,6 +1976 ,8 @@ static int64_t http_seek_internal(URLContext *h, int64_t off, int whence, int fo
7272 return s->off;
7373 }
7474
@@ -77,7 +77,7 @@ index 06f1bdd..7c60a66 100644
7777 /* if the location changed (redirect), revert to the original uri */
7878 if (strcmp(s->uri, s->location)) {
7979 char *new_uri;
80- @@ -1969 ,6 +1987 ,9 @@ static int64_t http_seek_internal(URLContext *h, int64_t off, int whence, int fo
80+ @@ -1966 ,6 +1986 ,9 @@ static int64_t http_seek_internal(URLContext *h, int64_t off, int whence, int fo
8181 return AVERROR(ENOMEM);
8282 av_free(s->location);
8383 s->location = new_uri;
0 commit comments