#566517 Closes connection prematurely

Package:
ample
Source:
ample
Description:
simple MP3 server easy to use
Submitter:
Adam Majer
Date:
2014-08-24 16:39:10 UTC
Severity:
normal
#566517#5
Date:
2010-01-23 18:08:46 UTC
From:
To:
 wget http://misc:1234/trance/blah.mp3
--2010-01-23 12:05:14--
http://misc:1234/trance/blah.mp3
Resolving misc... 192.168.53.45
Connecting to misc|192.168.53.45|:1234... connected.
HTTP request sent, awaiting response... 200 OK
Length: 72100087 (69M) [audio/mpeg]
Saving to: `blah.mp3'

99% [=================================================> ] 72,099,959
11.1M/s   in 6.3s

2010-01-23 12:05:20 (10.9 MB/s) - Connection closed at byte
72099959. Retrying.

#566517#10
Date:
2014-08-24 16:28:52 UTC
From:
To:
I was still able to reproduce the problem with the latest version of
"ample" in Debian sid/unstable (0.5.7-7), so I had a look at the problem.

It became obvious quickly that the problem was related to some stripping
of the mp3 files (removal of the ID3v1 from the end of the file and
ID3v2 from the beginning of the file) that was taken into account during
the streaming, but not during the preparation of the HTTP response
headers. Unfortunately, with the current function structure that
information was not available at the time of sending the HTTP response
headers. So some refactoring had to be done.

The good new is that the rewriting of the code fixes two more problems
that had not yet been reported to Debian so far: 1. The interpretation
of the positioning information in the HTTP "Range" header was not
consistent with the offsets (stripping ID3 info). 2. Regardless the
"Range" information, ample always sent the complete file, not only the
requested range (although its response header suggested partial content).

Find attached the proposed patch. It may need some further testing, I'm
not familiar with real-world use cases, so after the fix-up I only
tested it according to theoretical specifications (using general-purpose
tools like curl, wget etc.). This testing only covers the single-file
delivery methods, but the main switch in the program tells me that there
are several others. They are not likely to be affected by this patch,
but if maybe someone has a real-world use-case ready, testing might be
worth it anyway...

Cheers,
Martin