Skip to content

Commit

Permalink
fix: do not manually parse content-type (#20538)
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz authored and John Kleinschmidt committed Oct 11, 2019
1 parent 6764231 commit 1b2c6a3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
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

0 comments on commit 1b2c6a3

Please sign in to comment.