Skip to content

Commit e466d9b

Browse files
committed
refactor: rename "flushHeaders" to "relayHeaders"
The flushHeaders method conflicts with the Node.js res.flushHeaders method which has a different behavior
1 parent 0c5da48 commit e466d9b

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/response.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ export class Response extends Macroable {
485485
/*
486486
* Pipe stream
487487
*/
488-
this.flushHeaders()
488+
this.relayHeaders()
489489
body.pipe(this.response)
490490
})
491491
}
@@ -570,7 +570,7 @@ export class Response extends Macroable {
570570
* Writes headers with the Node.js res object using the
571571
* response.setHeader method
572572
*/
573-
flushHeaders() {
573+
relayHeaders() {
574574
if (!this.headersSent) {
575575
for (let key in this.#headers) {
576576
const value = this.#headers[key]

tests/response.spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ test.group('Response', (group) => {
5656
// @ts-expect-error
5757
response.header('content-type', undefined)
5858

59-
response.flushHeaders()
59+
response.relayHeaders()
6060
res.end()
6161
})
6262

@@ -72,7 +72,7 @@ test.group('Response', (group) => {
7272

7373
const contentType = response.getHeader('Content-Type')
7474

75-
response.flushHeaders()
75+
response.relayHeaders()
7676
res.end(JSON.stringify({ contentType }))
7777
})
7878

@@ -93,7 +93,7 @@ test.group('Response', (group) => {
9393

9494
const contentType = response.getHeader('Content-Type')
9595

96-
response.flushHeaders()
96+
response.relayHeaders()
9797
res.end(JSON.stringify({ contentType }))
9898
})
9999

@@ -114,7 +114,7 @@ test.group('Response', (group) => {
114114

115115
response.header('x-powered-by', 'adonisjs')
116116

117-
response.flushHeaders()
117+
response.relayHeaders()
118118
res.end(JSON.stringify(response.getHeaders()))
119119
})
120120

@@ -153,7 +153,7 @@ test.group('Response', (group) => {
153153
// @ts-expect-error
154154
response.append('set-cookie', undefined)
155155

156-
response.flushHeaders()
156+
response.relayHeaders()
157157
res.end()
158158
})
159159

@@ -166,7 +166,7 @@ test.group('Response', (group) => {
166166
const response = new ResponseFactory().merge({ req, res, encryption, router }).create()
167167

168168
response.append('set-cookie', 'age=22')
169-
response.flushHeaders()
169+
response.relayHeaders()
170170
res.end()
171171
})
172172

@@ -180,7 +180,7 @@ test.group('Response', (group) => {
180180

181181
response.append('set-cookie', ['username=virk'])
182182
response.append('set-cookie', ['age=22'])
183-
response.flushHeaders()
183+
response.relayHeaders()
184184
res.end()
185185
})
186186

@@ -194,7 +194,7 @@ test.group('Response', (group) => {
194194

195195
response.header('content-type', 'application/json')
196196
response.safeHeader('content-type', 'text/html')
197-
response.flushHeaders()
197+
response.relayHeaders()
198198
res.end()
199199
})
200200

@@ -207,7 +207,7 @@ test.group('Response', (group) => {
207207

208208
response.header('content-type', 'application/json')
209209
response.removeHeader('content-type')
210-
response.flushHeaders()
210+
response.relayHeaders()
211211
res.end()
212212
})
213213

@@ -220,7 +220,7 @@ test.group('Response', (group) => {
220220
const response = new ResponseFactory().merge({ req, res, encryption, router }).create()
221221

222222
response.status(201)
223-
response.flushHeaders()
223+
response.relayHeaders()
224224
res.end()
225225
})
226226

0 commit comments

Comments
 (0)