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: do not manually parse content-type #20538

Merged
merged 1 commit into from Oct 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions shell/browser/net/atom_url_loader_factory.cc
Expand Up @@ -123,9 +123,8 @@ network::ResourceResponseHead ToResponseHead(const mate::Dictionary& dict) {
}
// Some apps are passing content-type via headers, which is not accepted
// in NetworkService.
if (base::ToLowerASCII(iter.first) == "content-type" &&
iter.second.is_string()) {
head.mime_type = iter.second.GetString();
if (base::ToLowerASCII(iter.first) == "content-type") {
head.headers->GetMimeTypeAndCharset(&head.mime_type, &head.charset);
has_content_type = true;
}
}
Expand Down
12 changes: 12 additions & 0 deletions spec-main/api-protocol-spec.ts
Expand Up @@ -469,6 +469,18 @@ describe('protocol module', () => {
expect(r.data).to.have.property('value').that.is.equal(1)
})

it('can set content-type with charset', async () => {
await interceptStringProtocol('http', (request, callback) => {
callback({
mimeType: 'application/json; charset=UTF-8',
data: '{"value": 1}'
})
})
const r = await ajax('http://fake-host')
expect(r.data).to.be.an('object')
expect(r.data).to.have.property('value').that.is.equal(1)
})

it('can receive post data', async () => {
await interceptStringProtocol('http', (request, callback) => {
const uploadData = request.uploadData[0].bytes.toString()
Expand Down