Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix playback service doesn't work with azure CDN with media optimization #204

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions tools/PlaybackService/src/Controllers/PlaybackController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -425,21 +425,20 @@ private async Task GetOtherFilesAsync(BlobClient blob, long contentLength)
throw new Exception($"Can't download the blob {blob.Uri}");
}

// Write the response.
if (range != null)
{
var readedLength = range.Value.Length ?? contentLength - range.Value.Offset;
Response.ContentLength = readedLength;
// Copy the http status code and response headers.
var blobServerResponse = blobStreamResponse.GetRawResponse();
Response.StatusCode = blobServerResponse.Status;

var contentRange = $"{range.Value.Offset}-{readedLength + range.Value.Offset - 1}/{contentLength}";
logger.LogDebug($"Add header Content-Range: {contentRange}");
Response.Headers.Add("Content-Range", contentRange);
}
else
// For security, we only expose the following headers:
foreach (var allowHeader in new[] { "Content-Length", "Content-Type", "Date", "Accept-Ranges", "Content-MD5", "ETag", "Last-Modified" })
{
Response.ContentLength = contentLength;
if (blobServerResponse.Headers.TryGetValue(allowHeader, out var header))
{
Response.Headers.TryAdd(allowHeader, header);
}
}

// Copy the body.
await blobStreamResponse.Value.Content.CopyToAsync(Response.Body).ConfigureAwait(false);

// All done.
Expand Down
Loading