feat(xo-server/callProxyMethod): support binary response (#5399)

This commit is contained in:
badrAZ
2020-11-25 18:16:20 +01:00
committed by GitHub
parent 7a8ca2f068
commit dedc4aa8b9
3 changed files with 11 additions and 1 deletions

View File

@@ -57,6 +57,7 @@
"body-parser": "^1.18.2",
"compression": "^1.7.3",
"connect-flash": "^0.1.1",
"content-type": "^1.0.4",
"cookie": "^0.4.0",
"cookie-parser": "^1.4.3",
"d3-time-format": "^3.0.0",

View File

@@ -1,3 +1,5 @@
import assert from 'assert'
import contentType from 'content-type'
import cookie from 'cookie'
import defer from 'golike-defer'
import hrp from 'http-request-plus'
@@ -354,6 +356,13 @@ export default class Proxy {
await this.updateProxy(id, { authenticationToken })
}
const responseType = contentType.parse(response).type
if (responseType === 'application/octet-stream') {
return response
}
assert.strictEqual(responseType, 'application/json')
const lines = pumpify.obj(response, split2(JSON.parse))
const firstLine = await readChunk(lines)

View File

@@ -5253,7 +5253,7 @@ content-security-policy-builder@2.1.0:
resolved "https://registry.yarnpkg.com/content-security-policy-builder/-/content-security-policy-builder-2.1.0.tgz#0a2364d769a3d7014eec79ff7699804deb8cfcbb"
integrity sha512-/MtLWhJVvJNkA9dVLAp6fg9LxD2gfI6R2Fi1hPmfjYXSahJJzcfvoeDOxSyp4NvxMuwWv3WMssE9o31DoULHrQ==
content-type@~1.0.1, content-type@~1.0.4:
content-type@^1.0.4, content-type@~1.0.1, content-type@~1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.4.tgz#e138cc75e040c727b1966fe5e5f8c9aee256fe3b"
integrity sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==