Skip to content

Commit be60100

Browse files
authored
fix(dash): increase dashboard header size limit (#850)
1 parent 718d1f2 commit be60100

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

pkg/cloud/gateway/gateway.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ func (s *LocalGatewayService) createApiServers() error {
650650
ReadTimeout: time.Second * 1,
651651
IdleTimeout: time.Second * 1,
652652
CloseOnShutdown: true,
653-
ReadBufferSize: 8192,
653+
ReadBufferSize: 64 * 1024, // Set to 64 KB to handle large headers
654654
Handler: s.handleApiHttpRequest(apiName),
655655
Logger: log.New(s.logWriter, fmt.Sprintf("%s: ", lis.Addr().String()), 0),
656656
}

pkg/dashboard/frontend/cypress/e2e/api-explorer.cy.ts

+25
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ const expectedEndpoints = [
2626
'my-secret-api-/set-binary-POST',
2727
]
2828

29+
function setLongCookie(name: string, value: string) {
30+
const maxSize = 4000 // Approximate max cookie size (4KB)
31+
const chunks = Math.ceil(value.length / maxSize) // Calculate the number of chunks needed
32+
33+
// Loop through and set each chunk as a separate cookie
34+
for (let i = 0; i < chunks; i++) {
35+
const chunkValue = value.substring(i * maxSize, (i + 1) * maxSize) // Get the current chunk of the value
36+
cy.setCookie(`${name}-${i}`, chunkValue) // Set the chunk as a cookie with the index in the name
37+
}
38+
}
39+
2940
describe('APIs spec', () => {
3041
beforeEach(() => {
3142
cy.viewport('macbook-16')
@@ -335,4 +346,18 @@ describe('APIs spec', () => {
335346
}
336347
})
337348
})
349+
350+
it('should handle big headers', () => {
351+
setLongCookie('long-header', 'a'.repeat(10000))
352+
353+
cy.intercept('/api/call/**').as('apiCall')
354+
355+
cy.get('[data-rct-item-id="first-api-/all-methods-GET"]').click()
356+
357+
cy.getTestEl('send-api-btn').click()
358+
359+
cy.wait('@apiCall')
360+
361+
cy.getTestEl('response-status', 5000).should('contain.text', 'Status: 200')
362+
})
338363
})

0 commit comments

Comments
 (0)