>From 70e6b700b1e3b03893b9fe3e60ac9d69bfbdd8a0 Mon Sep 17 00:00:00 2001
From: Bill C Riemers <docbill@hartnell.local>
Date: Mon, 16 Jun 2008 11:46:47 -0400
Subject: [PATCH] Bug fix: Do not close an http stream when seeking out of range.

---
 modules/access/http.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/modules/access/http.c b/modules/access/http.c
index e397a1f..a5cfefd 100644
--- a/modules/access/http.c
+++ b/modules/access/http.c
@@ -881,6 +881,20 @@ static int Seek( access_t *p_access, int64_t i_pos )
 
     Disconnect( p_access );
 
+    if( i_pos < 0 ) {
+        msg_Err( p_access, "seek to soon" );
+        i_pos = 0;
+    }
+    if(p_access->info.i_size > 0 && i_pos >= p_access->info.i_size ) {
+        msg_Err( p_access, "seek to far" );
+        int retval = Seek( p_access, p_access->info.i_size - 1 );
+        if( retval == VLC_SUCCESS ) {
+            uint8_t p_buffer[2];
+            Read( p_access, p_buffer, 1);
+            p_access->info.b_eof  = false;
+        }
+        return retval;
+    }
     if( Connect( p_access, i_pos ) )
     {
         msg_Err( p_access, "seek failed" );
-- 
1.5.5.1

