/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
mozilla::net::ContentRange::ContentRange(const nsACString& aRangeHeader,
uint64_t aSize)
: mStart(0), mEnd(0), mSize(0) { auto parsed = nsContentUtils::ParseSingleRangeRequest(aRangeHeader, true); // https://fetch.spec.whatwg.org/#ref-for-simple-range-header-value%E2%91%A1 // If rangeValue is failure, then return a network error. if (!parsed) { return;
}
// Sanity check: ParseSingleRangeRequest should handle these two cases. // If rangeEndValue and rangeStartValue are null, then return failure.
MOZ_ASSERT(parsed->Start().isSome() || parsed->End().isSome()); // If rangeStartValue and rangeEndValue are numbers, and rangeStartValue // is greater than rangeEndValue, then return failure.
MOZ_ASSERT(parsed->Start().isNothing() || parsed->End().isNothing() ||
*parsed->Start() <= *parsed->End());
// Set rangeEnd to rangeStart + rangeEnd − 1.
mEnd = mStart + *parsed->End() - 1;
// Otherwise:
} else { // If rangeStart is greater than or equal to fullLength, then return a // network error. if (*parsed->Start() >= aSize) { return;
}
mStart = *parsed->Start();
// If rangeEnd is null or rangeEnd is greater than or equal to fullLength, // then set rangeEnd to fullLength − 1. if (parsed->End().isNothing() || *parsed->End() >= aSize) {
mEnd = aSize - 1;
} else {
mEnd = *parsed->End();
}
}
mSize = aSize;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.