|
|
@@ -350,12 +350,11 @@ static int process_line(URLContext *h, char *line, int line_count, |
|
|
|
|
|
|
|
|
/* error codes are 4xx and 5xx, but regard 401 as a success, so we |
|
|
/* error codes are 4xx and 5xx, but regard 401 as a success, so we |
|
|
* don't abort until all headers have been parsed. */ |
|
|
* don't abort until all headers have been parsed. */ |
|
|
if (s->http_code >= 400 && s->http_code < 600 && (s->http_code != 401 |
|
|
|
|
|
|| s->auth_state.auth_type != HTTP_AUTH_NONE) && |
|
|
|
|
|
|
|
|
if (s->http_code >= 400 && s->http_code < 600 && |
|
|
|
|
|
(s->http_code != 401 || s->auth_state.auth_type != HTTP_AUTH_NONE) && |
|
|
(s->http_code != 407 || s->proxy_auth_state.auth_type != HTTP_AUTH_NONE)) { |
|
|
(s->http_code != 407 || s->proxy_auth_state.auth_type != HTTP_AUTH_NONE)) { |
|
|
end += strspn(end, SPACE_CHARS); |
|
|
end += strspn(end, SPACE_CHARS); |
|
|
av_log(h, AV_LOG_WARNING, "HTTP error %d %s\n", |
|
|
|
|
|
s->http_code, end); |
|
|
|
|
|
|
|
|
av_log(h, AV_LOG_WARNING, "HTTP error %d %s\n", s->http_code, end); |
|
|
return AVERROR(EIO); |
|
|
return AVERROR(EIO); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
@@ -379,12 +378,12 @@ static int process_line(URLContext *h, char *line, int line_count, |
|
|
av_free(s->location); |
|
|
av_free(s->location); |
|
|
s->location = new_loc; |
|
|
s->location = new_loc; |
|
|
*new_location = 1; |
|
|
*new_location = 1; |
|
|
} else if (!av_strcasecmp (tag, "Content-Length") && s->filesize == -1) { |
|
|
|
|
|
|
|
|
} else if (!av_strcasecmp(tag, "Content-Length") && s->filesize == -1) { |
|
|
s->filesize = strtoll(p, NULL, 10); |
|
|
s->filesize = strtoll(p, NULL, 10); |
|
|
} else if (!av_strcasecmp (tag, "Content-Range")) { |
|
|
|
|
|
|
|
|
} else if (!av_strcasecmp(tag, "Content-Range")) { |
|
|
/* "bytes $from-$to/$document_size" */ |
|
|
/* "bytes $from-$to/$document_size" */ |
|
|
const char *slash; |
|
|
const char *slash; |
|
|
if (!strncmp (p, "bytes ", 6)) { |
|
|
|
|
|
|
|
|
if (!strncmp(p, "bytes ", 6)) { |
|
|
p += 6; |
|
|
p += 6; |
|
|
s->off = strtoll(p, NULL, 10); |
|
|
s->off = strtoll(p, NULL, 10); |
|
|
if ((slash = strchr(p, '/')) && strlen(slash) > 0) |
|
|
if ((slash = strchr(p, '/')) && strlen(slash) > 0) |
|
|
@@ -392,18 +391,21 @@ static int process_line(URLContext *h, char *line, int line_count, |
|
|
} |
|
|
} |
|
|
if (s->seekable == -1 && (!s->is_akamai || s->filesize != 2147483647)) |
|
|
if (s->seekable == -1 && (!s->is_akamai || s->filesize != 2147483647)) |
|
|
h->is_streamed = 0; /* we _can_ in fact seek */ |
|
|
h->is_streamed = 0; /* we _can_ in fact seek */ |
|
|
} else if (!av_strcasecmp(tag, "Accept-Ranges") && !strncmp(p, "bytes", 5) && s->seekable == -1) { |
|
|
|
|
|
|
|
|
} else if (!av_strcasecmp(tag, "Accept-Ranges") && |
|
|
|
|
|
!strncmp(p, "bytes", 5) && |
|
|
|
|
|
s->seekable == -1) { |
|
|
h->is_streamed = 0; |
|
|
h->is_streamed = 0; |
|
|
} else if (!av_strcasecmp (tag, "Transfer-Encoding") && !av_strncasecmp(p, "chunked", 7)) { |
|
|
|
|
|
|
|
|
} else if (!av_strcasecmp(tag, "Transfer-Encoding") && |
|
|
|
|
|
!av_strncasecmp(p, "chunked", 7)) { |
|
|
s->filesize = -1; |
|
|
s->filesize = -1; |
|
|
s->chunksize = 0; |
|
|
s->chunksize = 0; |
|
|
} else if (!av_strcasecmp (tag, "WWW-Authenticate")) { |
|
|
|
|
|
|
|
|
} else if (!av_strcasecmp(tag, "WWW-Authenticate")) { |
|
|
ff_http_auth_handle_header(&s->auth_state, tag, p); |
|
|
ff_http_auth_handle_header(&s->auth_state, tag, p); |
|
|
} else if (!av_strcasecmp (tag, "Authentication-Info")) { |
|
|
|
|
|
|
|
|
} else if (!av_strcasecmp(tag, "Authentication-Info")) { |
|
|
ff_http_auth_handle_header(&s->auth_state, tag, p); |
|
|
ff_http_auth_handle_header(&s->auth_state, tag, p); |
|
|
} else if (!av_strcasecmp (tag, "Proxy-Authenticate")) { |
|
|
|
|
|
|
|
|
} else if (!av_strcasecmp(tag, "Proxy-Authenticate")) { |
|
|
ff_http_auth_handle_header(&s->proxy_auth_state, tag, p); |
|
|
ff_http_auth_handle_header(&s->proxy_auth_state, tag, p); |
|
|
} else if (!av_strcasecmp (tag, "Connection")) { |
|
|
|
|
|
|
|
|
} else if (!av_strcasecmp(tag, "Connection")) { |
|
|
if (!strcmp(p, "close")) |
|
|
if (!strcmp(p, "close")) |
|
|
s->willclose = 1; |
|
|
s->willclose = 1; |
|
|
} else if (!av_strcasecmp (tag, "Server")) { |
|
|
} else if (!av_strcasecmp (tag, "Server")) { |
|
|
@@ -438,8 +440,9 @@ static int process_line(URLContext *h, char *line, int line_count, |
|
|
return AVERROR(ENOMEM); |
|
|
return AVERROR(ENOMEM); |
|
|
av_freep(&s->icy_metadata_headers); |
|
|
av_freep(&s->icy_metadata_headers); |
|
|
s->icy_metadata_headers = buf; |
|
|
s->icy_metadata_headers = buf; |
|
|
} else if (!av_strcasecmp (tag, "Content-Encoding")) { |
|
|
|
|
|
if (!av_strncasecmp(p, "gzip", 4) || !av_strncasecmp(p, "deflate", 7)) { |
|
|
|
|
|
|
|
|
} else if (!av_strcasecmp(tag, "Content-Encoding")) { |
|
|
|
|
|
if (!av_strncasecmp(p, "gzip", 4) || |
|
|
|
|
|
!av_strncasecmp(p, "deflate", 7)) { |
|
|
#if CONFIG_ZLIB |
|
|
#if CONFIG_ZLIB |
|
|
s->compressed = 1; |
|
|
s->compressed = 1; |
|
|
inflateEnd(&s->inflate_stream); |
|
|
inflateEnd(&s->inflate_stream); |
|
|
|