Merge pull request #7734 from Budibase/fix/cr-header

Fix/cr header
This commit is contained in:
Martin McKeaveney 2022-09-12 12:22:35 +01:00 committed by GitHub
commit 8a3126826d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 54 additions and 1083 deletions

File diff suppressed because it is too large Load Diff

View File

@ -34,6 +34,7 @@ export interface RestConfig {
defaultHeaders: { defaultHeaders: {
[key: string]: any [key: string]: any
} }
legacyHttpParser: boolean
authConfigs: AuthConfig[] authConfigs: AuthConfig[]
staticVariables: { staticVariables: {
[key: string]: string [key: string]: string

View File

@ -80,6 +80,12 @@ module RestModule {
required: false, required: false,
default: {}, default: {},
}, },
legacyHttpParser: {
display: "Legacy HTTP Support",
type: DatasourceFieldType.BOOLEAN,
required: false,
default: false,
},
}, },
query: { query: {
create: { create: {
@ -379,6 +385,11 @@ module RestModule {
paginationValues paginationValues
) )
if (this.config.legacyHttpParser) {
// https://github.com/nodejs/node/issues/43798
input.extraHttpOptions = { insecureHTTPParser: true }
}
this.startTimeMs = performance.now() this.startTimeMs = performance.now()
const url = this.getUrl(path, queryString, pagination, paginationValues) const url = this.getUrl(path, queryString, pagination, paginationValues)
const response = await fetch(url, input) const response = await fetch(url, input)

View File

@ -547,4 +547,21 @@ describe("REST Integration", () => {
}) })
}) })
}) })
describe("Configuration options", () => {
it("Attaches insecureHttpParams when legacy HTTP Parser option is set", async () => {
config = new TestConfiguration({
url: BASE_URL,
legacyHttpParser: true
})
await config.integration.read({})
expect(fetch).toHaveBeenCalledWith(`${BASE_URL}/?`, {
method: "GET",
headers: {},
extraHttpOptions: {
insecureHTTPParser: true
}
})
})
})
}) })