input/curl: forget Content-Length (and more) after redirect
Fixes playback of redirected streams.
This commit is contained in:
parent
a2eb14f3b3
commit
56f763a4a8
2
NEWS
2
NEWS
|
@ -1,4 +1,6 @@
|
||||||
ver 0.19.2 (not yet released)
|
ver 0.19.2 (not yet released)
|
||||||
|
* input
|
||||||
|
- curl: fix redirected streams
|
||||||
* playlist
|
* playlist
|
||||||
- don't allow empty playlist name
|
- don't allow empty playlist name
|
||||||
- m3u: don't ignore unterminated last line
|
- m3u: don't ignore unterminated last line
|
||||||
|
|
|
@ -109,6 +109,13 @@ struct CurlInputStream final : public AsyncInputStream {
|
||||||
*/
|
*/
|
||||||
void FreeEasyIndirect();
|
void FreeEasyIndirect();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a new response begins. This is used to discard
|
||||||
|
* headers from previous responses (for example authentication
|
||||||
|
* and redirects).
|
||||||
|
*/
|
||||||
|
void ResponseBoundary();
|
||||||
|
|
||||||
void HeaderReceived(const char *name, std::string &&value);
|
void HeaderReceived(const char *name, std::string &&value);
|
||||||
|
|
||||||
size_t DataReceived(const void *ptr, size_t size);
|
size_t DataReceived(const void *ptr, size_t size);
|
||||||
|
@ -597,6 +604,20 @@ CurlInputStream::~CurlInputStream()
|
||||||
FreeEasyIndirect();
|
FreeEasyIndirect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
CurlInputStream::ResponseBoundary()
|
||||||
|
{
|
||||||
|
/* undo all effects of HeaderReceived() because the previous
|
||||||
|
response was not applicable for this stream */
|
||||||
|
|
||||||
|
seekable = false;
|
||||||
|
size = UNKNOWN_SIZE;
|
||||||
|
ClearMimeType();
|
||||||
|
ClearTag();
|
||||||
|
|
||||||
|
// TODO: reset the IcyInputStream?
|
||||||
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
CurlInputStream::HeaderReceived(const char *name, std::string &&value)
|
CurlInputStream::HeaderReceived(const char *name, std::string &&value)
|
||||||
{
|
{
|
||||||
|
@ -645,6 +666,11 @@ input_curl_headerfunction(void *ptr, size_t size, size_t nmemb, void *stream)
|
||||||
size *= nmemb;
|
size *= nmemb;
|
||||||
|
|
||||||
const char *header = (const char *)ptr;
|
const char *header = (const char *)ptr;
|
||||||
|
if (size > 5 && memcmp(header, "HTTP/", 5) == 0) {
|
||||||
|
c.ResponseBoundary();
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
const char *end = header + size;
|
const char *end = header + size;
|
||||||
|
|
||||||
char name[64];
|
char name[64];
|
||||||
|
|
Loading…
Reference in New Issue