Skip to content

Commit

Permalink
fixed crash issue in no content-type situation.
Browse files Browse the repository at this point in the history
  • Loading branch information
netptop committed Mar 14, 2020
1 parent 9fbbedd commit 98715e5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ let Proxy = ({urlModify, httpprefix, serverName, port, cookieDomainRewrite, loca
// res.status(404).send(`{"error": "${e}"}`)
return
}
if (proxyRes.headers["content-type"].indexOf('text/') !== -1 ||
if (!proxyRes.headers["content-type"] ||
proxyRes.headers["content-type"].indexOf('text/') !== -1 ||
proxyRes.headers["content-type"].indexOf('javascript') !== -1 ||
proxyRes.headers["content-type"].indexOf('urlencoded') !== -1 ||
proxyRes.headers["content-type"].indexOf('json') !== -1) {
Expand Down
14 changes: 14 additions & 0 deletions test/siteproxylocal.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,17 @@ test('youtube homepage issue', async () => {
// h2020-03-13T23:24:08.403097+00:00 app[web.1]: httpType:https, host:id.google.com



test('no content-type field situation', async () => {
const url = `${httpprefix}://${serverName}:${port}/https/onetag-sys.com/usync/?pubId=5927d926323dc2c`
const response = await axios({
method: 'get',
headers: {
'Accept': `text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9`,
},
url,
})
// console.log(`${JSON.stringify(response.headers)}`)
// console.log(`${response.data}`)
expect(typeof(response.data)).toBe('object')
}, 15000); // should be done within 3 seconds.

0 comments on commit 98715e5

Please sign in to comment.