Skip to content

Commit

Permalink
fix(helper/proxy): return Content-Range header as it is
Browse files Browse the repository at this point in the history
Co-authored-by: Haochen M. Kotoi-Xie <haochenx@acm.org>
  • Loading branch information
usualoma and haochenx committed Oct 30, 2024
1 parent ad17d90 commit 5998770
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/helper/proxy/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('Proxy Middleware', () => {
headers: {
'Content-Encoding': 'gzip',
'Content-Length': '100',
'Content-Range': '100-200',
'Content-Range': 'bytes 0-2/1024',
'X-Response-Id': '456',
},
})
Expand Down Expand Up @@ -39,7 +39,7 @@ describe('Proxy Middleware', () => {
expect(res.headers.get('X-Response-Id')).toBe('456')
expect(res.headers.get('Content-Encoding')).toBeNull()
expect(res.headers.get('Content-Length')).toBeNull()
expect(res.headers.get('Content-Range')).toBeNull()
expect(res.headers.get('Content-Range')).toBe('bytes 0-2/1024')
})

it('proxySetRequestHeaders option', async () => {
Expand Down Expand Up @@ -77,7 +77,7 @@ describe('Proxy Middleware', () => {
expect(res.headers.get('X-Response-Id')).toBe('456')
expect(res.headers.get('Content-Encoding')).toBeNull()
expect(res.headers.get('Content-Length')).toBeNull()
expect(res.headers.get('Content-Range')).toBeNull()
expect(res.headers.get('Content-Range')).toBe('bytes 0-2/1024')
})

it('proxySetRequestHeaderNames option', async () => {
Expand Down Expand Up @@ -106,7 +106,7 @@ describe('Proxy Middleware', () => {
expect(res.headers.get('X-Response-Id')).toBeNull()
expect(res.headers.get('Content-Encoding')).toBeNull()
expect(res.headers.get('Content-Length')).toBeNull()
expect(res.headers.get('Content-Range')).toBeNull()
expect(res.headers.get('Content-Range')).toBe('bytes 0-2/1024')
})
})
})
3 changes: 1 addition & 2 deletions src/helper/proxy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
* The following headers will be deleted from the response:
* * Content-Encoding
* * Content-Length
* * Content-Range
*/
const forceDeleteResponseHeaderNames = ['Content-Encoding', 'Content-Length', 'Content-Range']
const forceDeleteResponseHeaderNames = ['Content-Encoding', 'Content-Length']

// Typical header names for requests for proxy use
type ProxyRequestHeaderName = 'X-Forwarded-For' | 'X-Forwarded-Proto' | 'X-Forwarded-Host'
Expand Down

0 comments on commit 5998770

Please sign in to comment.