зеркало из https://github.com/electron/electron.git
fix: do not manually parse content-type (#20538)
This commit is contained in:
Родитель
67642312f4
Коммит
1b2c6a33b3
|
@ -123,9 +123,8 @@ network::ResourceResponseHead ToResponseHead(const mate::Dictionary& dict) {
|
||||||
}
|
}
|
||||||
// Some apps are passing content-type via headers, which is not accepted
|
// Some apps are passing content-type via headers, which is not accepted
|
||||||
// in NetworkService.
|
// in NetworkService.
|
||||||
if (base::ToLowerASCII(iter.first) == "content-type" &&
|
if (base::ToLowerASCII(iter.first) == "content-type") {
|
||||||
iter.second.is_string()) {
|
head.headers->GetMimeTypeAndCharset(&head.mime_type, &head.charset);
|
||||||
head.mime_type = iter.second.GetString();
|
|
||||||
has_content_type = true;
|
has_content_type = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -469,6 +469,18 @@ describe('protocol module', () => {
|
||||||
expect(r.data).to.have.property('value').that.is.equal(1)
|
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 () => {
|
it('can receive post data', async () => {
|
||||||
await interceptStringProtocol('http', (request, callback) => {
|
await interceptStringProtocol('http', (request, callback) => {
|
||||||
const uploadData = request.uploadData[0].bytes.toString()
|
const uploadData = request.uploadData[0].bytes.toString()
|
||||||
|
|
Загрузка…
Ссылка в новой задаче