Repository navigation
Conversation
…e other TAF A box resumes a download with Range and, in If-Range, the audio id of the TAF it has the first part of. When the tag's source was changed to another TAF meanwhile, local content is served from the Range on regardless: the box gets the rest of the new TAF after the start of the old one. Marked as an expected failure until fixed.
…e file A box resumes a download with Range and the audio id of the TAF it has the first part of in If-Range. Local content was served from the Range on regardless, so when the tag's source had been changed to another TAF, the box completed the start of the old TAF with the rest of the new one. As for any If-Range whose validator does not match the representation (RFC 9110 13.1.5), the Range is now ignored and the whole file is sent with 200. The validator is the audio id in the header of the file that is sent, also with skip_header and for a V3 chapter. Only an If-Range that is a decimal number fitting an audio id is compared, as the boxes send it. Any other value (an ETag, a date, a number with text after it) is not TeddyCloud's to judge, and the Range is served as before, so that a client does not lose its resume over it; so is a matching or absent If-Range. Live streams (ffmpeg, TAP streams) are not changed: they decide about a Range themselves. A random TAP pool already uses If-Range to pick the TAF it resumes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A box that resumes a download sends
Range: bytes=<n>-and, inIf-Range, the audio id (decimal) of the TAF ithas the first part of. TeddyCloud served local content (a cached tonie, a library TAF, a custom source) from the
Range on without looking at If-Range. If the tag's source was changed to another TAF in the meantime, the box
completed the start of the old TAF with the rest of the new one, leaving a mix of two TAFs on its SD card.
Now a Range request whose If-Range is a decimal audio id other than the one of the file being sent gets the whole
file: 200, no Content-Range. HTTP prescribes this for an If-Range whose validator does not match (RFC 9110
13.1.5). A matching or absent If-Range is served as before, and so is an If-Range that is not a decimal number.
Why
Found before it hit a real box: a box had the first 30.4 MB of a tag's TAF on its card when the tag's source was
to be changed to another TAF. Its next resume would be
Range: bytes=30425088-withIf-Range: <old audio id>,and TeddyCloud would answer 206 from 30.4 MB of the new file: the repro test below shows exactly that answer.
How
ignoreRangeOfAnotherTaf()in src/handler_cloud.c, on the "Serve local content" path just beforehttpExtSendResponseStream. When If-Range is a decimal number that fits an audio id and is not the audio id in theheader of the file being served (
tonieInfo->tafHeader), it drops the Range (Range.valid = false, start and end0). The same validator therefore holds:
pickPoolTafalready picks the TAF the If-Range names, so the check matches.Only a decimal number is compared, because that is what the boxes send: the stock CC3200 does, and develop's
random-pool code assumes the same. Any other value is not ours to judge, and the Range is served as before. That
covers an ETag, a date, a number with text after it, or one too large for an audio id. TeddyCloud sends no
validator for this content, and what other clients (an ESP32 box, a browser) might send is unknown. A client whose
validator cannot be compared should not lose its resume; on a slow link a resume that restarts at 0 may never
finish.
Not changed:
Tested
IfRangecases in tests/py/test_taf_serving.py. The local-content setup moved into a base classTafContent, so the new class does not run the existing tests again.CONTENT, then its source was changed toanother TAF in the library, and a request came with Range 20000- and If-Range of the old audio id. Before the
fix:
206, bytes 20000-28671/28672with the other TAF's bytes. After: 200 with the whole new file.<id>abc,99999999999): 206 as before;test_tap_random,test_http_range,test_taf_redownloadand fullmake testpass. Every pytest entry wasalso run with its server log kept: no ASan/UBSan report apart from the known protobuf-c shift in test_box_sim.