aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/http.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2010-08-09 08:14:48 +0000
committerMartin Storsjö <martin@martin.st>2010-08-09 08:14:48 +0000
commitf240ed18efd80abc6df0bdce13cf0ca708f283ae (patch)
tree655c3f92fa78ff9f781174294553392b7050954b /libavformat/http.c
parent46a76dec932d496a1482b359106cf313e20ea946 (diff)
downloadffmpeg-f240ed18efd80abc6df0bdce13cf0ca708f283ae.tar.gz
http: Return EOF at the end of the content even if the connection isn't closed
We do request Connection: close, but some servers ignore it. Originally committed as revision 24746 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/http.c')
-rw-r--r--libavformat/http.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavformat/http.c b/libavformat/http.c
index eae780c2f8..75bfd3a5f4 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -49,6 +49,7 @@ typedef struct {
char location[URL_SIZE];
HTTPAuthState auth_state;
unsigned char headers[BUFFER_SIZE];
+ 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)
@@ -267,6 +268,9 @@ static int process_line(URLContext *h, char *line, int line_count,
ff_http_auth_handle_header(&s->auth_state, tag, p);
} else if (!strcmp (tag, "Authentication-Info")) {
ff_http_auth_handle_header(&s->auth_state, tag, p);
+ } else if (!strcmp (tag, "Connection")) {
+ if (!strcmp(p, "close"))
+ s->willclose = 1;
}
}
return 1;
@@ -337,6 +341,7 @@ static int http_connect(URLContext *h, const char *path, const char *hoststr,
s->line_count = 0;
s->off = 0;
s->filesize = -1;
+ s->willclose = 0;
if (post) {
/* 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
@@ -399,6 +404,8 @@ static int http_read(URLContext *h, uint8_t *buf, int size)
memcpy(buf, s->buf_ptr, len);
s->buf_ptr += len;
} else {
+ if (!s->willclose && s->filesize >= 0 && s->off >= s->filesize)
+ return AVERROR_EOF;
len = url_read(s->hd, buf, size);
}
if (len > 0) {