@@ -91,8 +91,6 @@ class Request {
91
91
92
92
this . abort = null
93
93
94
- this . publicInterface = null
95
-
96
94
if ( body == null ) {
97
95
this . body = null
98
96
} else if ( isStream ( body ) ) {
@@ -189,32 +187,10 @@ class Request {
189
187
this [ kHandler ] = handler
190
188
191
189
if ( channels . create . hasSubscribers ) {
192
- channels . create . publish ( { request : this . getPublicInterface ( ) } )
190
+ channels . create . publish ( { request : this } )
193
191
}
194
192
}
195
193
196
- getPublicInterface ( ) {
197
- const self = this
198
- this . publicInterface ??= {
199
- get origin ( ) {
200
- return self . origin
201
- } ,
202
- get method ( ) {
203
- return self . method
204
- } ,
205
- get path ( ) {
206
- return self . path
207
- } ,
208
- get headers ( ) {
209
- return self . headers
210
- } ,
211
- get completed ( ) {
212
- return self . completed
213
- }
214
- }
215
- return this . publicInterface
216
- }
217
-
218
194
onBodySent ( chunk ) {
219
195
if ( this [ kHandler ] . onBodySent ) {
220
196
try {
@@ -227,7 +203,7 @@ class Request {
227
203
228
204
onRequestSent ( ) {
229
205
if ( channels . bodySent . hasSubscribers ) {
230
- channels . bodySent . publish ( { request : this . getPublicInterface ( ) } )
206
+ channels . bodySent . publish ( { request : this } )
231
207
}
232
208
233
209
if ( this [ kHandler ] . onRequestSent ) {
@@ -260,7 +236,7 @@ class Request {
260
236
assert ( ! this . completed )
261
237
262
238
if ( channels . headers . hasSubscribers ) {
263
- channels . headers . publish ( { request : this . getPublicInterface ( ) , response : { statusCode, headers, statusText } } )
239
+ channels . headers . publish ( { request : this , response : { statusCode, headers, statusText } } )
264
240
}
265
241
266
242
try {
@@ -296,7 +272,7 @@ class Request {
296
272
297
273
this . completed = true
298
274
if ( channels . trailers . hasSubscribers ) {
299
- channels . trailers . publish ( { request : this . getPublicInterface ( ) , trailers } )
275
+ channels . trailers . publish ( { request : this , trailers } )
300
276
}
301
277
302
278
try {
@@ -311,7 +287,7 @@ class Request {
311
287
this . onFinally ( )
312
288
313
289
if ( channels . error . hasSubscribers ) {
314
- channels . error . publish ( { request : this . getPublicInterface ( ) , error } )
290
+ channels . error . publish ( { request : this , error } )
315
291
}
316
292
317
293
if ( this . aborted ) {
@@ -333,6 +309,11 @@ class Request {
333
309
this . endHandler = null
334
310
}
335
311
}
312
+
313
+ addHeader ( key , value ) {
314
+ processHeader ( this , key , value )
315
+ return this
316
+ }
336
317
}
337
318
338
319
function processHeader ( request , key , val ) {
0 commit comments