int len = strlen(s->headers);
if (len < 2 || strcmp("\r\n", s->headers + len - 2)) {
av_log(h, AV_LOG_WARNING,
- "No trailing CRLF found in HTTP header.\n");
+ "No trailing CRLF found in HTTP header. Adding it.\n");
ret = av_reallocp(&s->headers, len + 3);
if (ret < 0)
return ret;
while (av_isspace(*p))
p++;
resource = p;
- while (!av_isspace(*p))
+ while (*p && !av_isspace(*p))
p++;
*(p++) = '\0';
av_log(h, AV_LOG_TRACE, "Requested resource: %s\n", resource);
return pos;
}
-static void update_metadata(HTTPContext *s, char *data)
+static void update_metadata(URLContext *h, char *data)
{
char *key;
char *val;
char *end;
char *next = data;
+ HTTPContext *s = h->priv_data;
while (*next) {
key = next;
val += 2;
av_dict_set(&s->metadata, key, val, 0);
+ av_log(h, AV_LOG_VERBOSE, "Metadata update for %s: %s\n", key, val);
next = end + 2;
}
data[len + 1] = 0;
if ((ret = av_opt_set(s, "icy_metadata_packet", data, 0)) < 0)
return ret;
- update_metadata(s, data);
+ update_metadata(h, data);
}
s->icy_data_read = 0;
remaining = s->icy_metaint;
av_freep(&s->inflate_buffer);
#endif /* CONFIG_ZLIB */
- if (!s->end_chunked_post)
+ if (s->hd && !s->end_chunked_post)
/* Close the write direction by sending the end of chunked encoding. */
ret = http_shutdown(h, h->flags);
if (s->off && h->is_streamed)
return AVERROR(ENOSYS);
+ /* do not try to make a new connection if seeking past the end of the file */
+ if (s->end_off || s->filesize != UINT64_MAX) {
+ uint64_t end_pos = s->end_off ? s->end_off : s->filesize;
+ if (s->off >= end_pos)
+ return s->off;
+ }
+
/* we save the old context in case the seek fails */
old_buf_size = s->buf_end - s->buf_ptr;
memcpy(old_buf, s->buf_ptr, old_buf_size);