1
0
Fork 0
mirror of synced 2024-06-01 18:20:18 +12:00

provide fix for CR header and backwards compatibility with legacy servers

This commit is contained in:
Martin McKeaveney 2022-09-12 10:00:05 +01:00
parent 5c07c17cdd
commit 8ef5324048
4 changed files with 53 additions and 1086 deletions

File diff suppressed because it is too large Load diff

View file

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

View file

@ -79,6 +79,11 @@ module RestModule {
required: false,
default: {},
},
legacyHttpParser: {
type: DatasourceFieldType.BOOLEAN,
required: false,
default: false,
},
},
query: {
create: {
@ -233,9 +238,6 @@ module RestModule {
pagination: PaginationConfig | null,
paginationValues: PaginationValues | null
) {
// https://github.com/nodejs/node/issues/43798
input.extraHttpOptions = { insecureHTTPParser: true }
if (!input.headers) {
input.headers = {}
}
@ -380,6 +382,11 @@ module RestModule {
paginationValues
)
if (this.config.legacyHttpParser) {
// https://github.com/nodejs/node/issues/43798
input.extraHttpOptions = { insecureHTTPParser: true }
}
this.startTimeMs = performance.now()
const url = this.getUrl(path, queryString, pagination, paginationValues)
const response = await fetch(url, input)

View file

@ -529,4 +529,21 @@ describe("REST Integration", () => {
expect(res.pagination.cursor).toEqual(123)
})
})
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
}
})
})
})
})