fix: passing content-length down the stream for intercepted requests (#25324)
* fix: pass content length if avilable in headers * fix: fixed unit test after changes video is being played for standard scheme when content-length is available * fix: fixed review remakrs added is_string check and changed stol to StringToInt64 * fix: fix test case name * fix: fixed typo
This commit is contained in:
parent
6356cd4018
commit
fec1c0b68b
2 changed files with 12 additions and 6 deletions
|
@ -9,6 +9,7 @@
|
|||
#include <utility>
|
||||
|
||||
#include "base/guid.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/storage_partition.h"
|
||||
#include "mojo/public/cpp/bindings/binding.h"
|
||||
|
@ -123,11 +124,16 @@ network::mojom::URLResponseHeadPtr ToResponseHead(
|
|||
} else {
|
||||
continue;
|
||||
}
|
||||
auto header_name_lowercase = base::ToLowerASCII(iter.first);
|
||||
|
||||
if (header_name_lowercase == "content-type") {
|
||||
// Some apps are passing content-type via headers, which is not accepted
|
||||
// in NetworkService.
|
||||
if (base::ToLowerASCII(iter.first) == "content-type") {
|
||||
head->headers->GetMimeTypeAndCharset(&head->mime_type, &head->charset);
|
||||
has_content_type = true;
|
||||
} else if (header_name_lowercase == "content-length" &&
|
||||
iter.second.is_string()) {
|
||||
base::StringToInt64(iter.second.GetString(), &head->content_length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -919,11 +919,11 @@ describe('protocol module', () => {
|
|||
await protocol.unregisterProtocol('stream');
|
||||
});
|
||||
|
||||
it('does not successfully play videos with stream: false on streaming protocols', async () => {
|
||||
await streamsResponses(standardScheme, 'error');
|
||||
it('successfully plays videos when content is buffered (stream: false)', async () => {
|
||||
await streamsResponses(standardScheme, 'play');
|
||||
});
|
||||
|
||||
it('successfully plays videos with stream: true on streaming protocols', async () => {
|
||||
it('successfully plays videos when streaming content (stream: true)', async () => {
|
||||
await streamsResponses('stream', 'play');
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue