summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/input/input_http.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/input/input_http.c b/src/input/input_http.c
index 05919863d..64a2c7045 100644
--- a/src/input/input_http.c
+++ b/src/input/input_http.c
@@ -600,8 +600,6 @@ static off_t http_plugin_get_current_pos (input_plugin_t *this_gen){
static off_t http_plugin_seek(input_plugin_t *this_gen, off_t offset, int origin) {
http_input_plugin_t *this = (http_input_plugin_t *) this_gen;
- /* only realtive forward-seeking is implemented */
-
if ((origin == SEEK_CUR) && (offset >= 0)) {
for (;((int)offset) - BUFSIZE > 0; offset -= BUFSIZE) {
@@ -611,6 +609,21 @@ static off_t http_plugin_seek(input_plugin_t *this_gen, off_t offset, int origin
http_plugin_read (this_gen, this->seek_buf, offset);
}
+ if (origin == SEEK_SET) {
+
+ if (offset < this->curpos)
+ printf ("http: cannot seek back! (%lld > %lld)\n", this->curpos, offset);
+ else {
+ offset -= this->curpos;
+
+ for (;((int)offset) - BUFSIZE > 0; offset -= BUFSIZE) {
+ http_plugin_read (this_gen, this->seek_buf, BUFSIZE);
+ }
+
+ http_plugin_read (this_gen, this->seek_buf, offset);
+ }
+ }
+
return this->curpos;
}