Files
shaka-player/lib/util/networking.js
T
Joey Parrish f539147d48 fix: Correct license headers in compiled output
This fixes all the license headers in the main library, which corrects
the appearance of the main license in the compiled output.

It seems that the `!` in the header forces the compiler to keep it in
the output.  I believe older compiler releases did this purely based
on `@license`.

Issue #2638

Change-Id: I7f0e918caad10c9af689c9d07672b7fe9be7b2f3
2020-06-09 16:05:09 -07:00

48 lines
1.3 KiB
JavaScript

/*! @license
* Shaka Player
* Copyright 2016 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
goog.provide('shaka.util.Networking');
/**
* A collection of shared utilities that bridge the gap between our networking
* code and the other parts of our code base. This is to allow
* |shaka.net.NetworkingEngine| to remain general.
*
* @final
*/
shaka.util.Networking = class {
/**
* Create a request message for a segment. Providing |start| and |end|
* will set the byte range. A non-zero start must be provided for |end| to
* be used.
*
* @param {!Array.<string>} uris
* @param {?number} start
* @param {?number} end
* @param {shaka.extern.RetryParameters} retryParameters
* @return {shaka.extern.Request}
*/
static createSegmentRequest(uris, start, end, retryParameters) {
const request = shaka.net.NetworkingEngine.makeRequest(
uris, retryParameters);
if (start == 0 && end == null) {
// This is a request for the entire segment. The Range header is not
// required. Note that some web servers don't accept Range headers, so
// don't set one if it's not strictly required.
} else {
if (end) {
request.headers['Range'] = 'bytes=' + start + '-' + end;
} else {
request.headers['Range'] = 'bytes=' + start + '-';
}
}
return request;
}
};