@@ -41,7 +41,7 @@ class IncomingBody {
4141 if ( incomingBody . #finished)
4242 throw new Error ( "incoming body already finished" ) ;
4343 incomingBody . #finished = true ;
44- return futureTrailersCreate ( new Fields ( [ ] ) , false ) ;
44+ return futureTrailersCreate ( ) ;
4545 }
4646 [ symbolDispose ] ( ) {
4747 if ( ! this . #finished) {
@@ -99,18 +99,24 @@ delete IncomingRequest._create;
9999
100100class FutureTrailers {
101101 _id = futureCnt ++ ;
102- #value;
103- #isError;
102+ #requested = false ;
104103 subscribe ( ) {
105- // TODO
104+ return pollableCreate ( 0 ) ;
106105 }
107106 get ( ) {
108- return { tag : this . #isError ? "err" : "ok" , val : this . #value } ;
107+ if ( this . #requested)
108+ return { tag : "err" } ;
109+ this . #requested = true ;
110+ return {
111+ tag : "ok" ,
112+ val : {
113+ tag : "ok" ,
114+ val : undefined ,
115+ }
116+ } ;
109117 }
110- static _create ( value , isError ) {
118+ static _create ( ) {
111119 const res = new FutureTrailers ( ) ;
112- res . #value = value ;
113- res . #isError = isError ;
114120 return res ;
115121 }
116122}
@@ -328,7 +334,7 @@ class OutgoingBody {
328334 * @param {Fields | undefined } trailers
329335 */
330336 static finish ( body , trailers ) {
331- if ( trailers ) throw new Error ( "Internal error: Trailers TODO" ) ;
337+ if ( trailers ) throw { tag : "internal- error" , val : "trailers unsupported" } ;
332338 // this will verify content length, and also verify not already finished
333339 // throwing errors as appropriate
334340 if ( body . #outputStreamId)
@@ -419,7 +425,17 @@ class FutureIncomingResponse {
419425 [ symbolDispose ] ( ) {
420426 if ( this . #pollId) ioCall ( FUTURE_DISPOSE | HTTP , this . #pollId) ;
421427 }
422- static _create ( method , scheme , authority , pathWithQuery , headers , body , connectTimeout , betweenBytesTimeout , firstByteTimeout ) {
428+ static _create (
429+ method ,
430+ scheme ,
431+ authority ,
432+ pathWithQuery ,
433+ headers ,
434+ body ,
435+ connectTimeout ,
436+ betweenBytesTimeout ,
437+ firstByteTimeout
438+ ) {
423439 const res = new FutureIncomingResponse ( ) ;
424440 res . #pollId = ioCall ( HTTP_CREATE_REQUEST , null , {
425441 method,
@@ -430,7 +446,7 @@ class FutureIncomingResponse {
430446 body,
431447 connectTimeout,
432448 betweenBytesTimeout,
433- firstByteTimeout
449+ firstByteTimeout,
434450 } ) ;
435451 return res ;
436452 }
0 commit comments