diff options
author | Max Kellermann <max@duempel.org> | 2014-11-02 12:59:45 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-11-02 13:00:28 +0100 |
commit | 56f763a4a83f6410b1bd9e1f8b41240df535ebc9 (patch) | |
tree | 73165472a4e8fc263ccb315b13a1982ba4b090c4 /src/input/plugins/CurlInputPlugin.cxx | |
parent | a2eb14f3b379c966b259825c91c154f475f13eb6 (diff) | |
download | mpd-56f763a4a83f6410b1bd9e1f8b41240df535ebc9.tar.gz mpd-56f763a4a83f6410b1bd9e1f8b41240df535ebc9.tar.xz mpd-56f763a4a83f6410b1bd9e1f8b41240df535ebc9.zip |
input/curl: forget Content-Length (and more) after redirect
Fixes playback of redirected streams.
Diffstat (limited to '')
-rw-r--r-- | src/input/plugins/CurlInputPlugin.cxx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/input/plugins/CurlInputPlugin.cxx b/src/input/plugins/CurlInputPlugin.cxx index 0028158a3..1e1a46108 100644 --- a/src/input/plugins/CurlInputPlugin.cxx +++ b/src/input/plugins/CurlInputPlugin.cxx @@ -109,6 +109,13 @@ struct CurlInputStream final : public AsyncInputStream { */ 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); size_t DataReceived(const void *ptr, size_t size); @@ -598,6 +605,20 @@ CurlInputStream::~CurlInputStream() } 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 CurlInputStream::HeaderReceived(const char *name, std::string &&value) { if (IsSeekPending()) @@ -645,6 +666,11 @@ input_curl_headerfunction(void *ptr, size_t size, size_t nmemb, void *stream) size *= nmemb; const char *header = (const char *)ptr; + if (size > 5 && memcmp(header, "HTTP/", 5) == 0) { + c.ResponseBoundary(); + return size; + } + const char *end = header + size; char name[64]; |