.HeaderField{Name: ":status", Value: "200"})
			headerFields = append(headerFields, hpack.HeaderField{Name: "content-type", Value: contentType(s.contentSubtype)})
		}
	}
	headerFields = append(headerFields, hpack.HeaderField{Name: "grpc-status", Value: strconv.Itoa(int(st.Code()))})
	headerFields = append(headerFields, hpack.HeaderField{Name: "grpc-message", Value: encodeGrpcMessage(st.Message())})

	if p := statusRawProto(st); p!= nil && len(p.Details) > 0 {
		stBytes, err := proto.Marshal(p)
		if err!= nil {
			// TODO: return error instead, when callers are able to handle it.
			grpclog.Errorf("transport: failed to marshal rpc status: %v, error: %v", p, err)
		} else {
			headerFields = append(headerFields, hpack.HeaderField{Name: "grpc-status-details-bin", Value: encodeBinHeader(stBytes)})
		}
	}

	// Attach the trailer metadata.
	headerFields = appendHeaderFieldsFromMD(headerFields, s.trailer)
	trailingHeader := &headerFrame{
		streamID:  s.id,
		hf:        headerFields,
		endStream: true,
		onWrite:   t.setResetPingStrikes,
	}
	s.hdrMu.Unlock()
	success, err := t.controlBuf.execute(t.checkForHeaderListSize, trailingHeader)
	if!success {
		if err!= nil {
			return err
		}
		t.closeStream(s, true, http2.ErrCodeInternal, false)
		return ErrHeaderListSizeLimitViolation
	}
	// Send a RST_STREAM after the trailers if the client has not already half-closed.
	rst := s.getState() == streamActive
	t.finishStream(s, rst, http2.ErrCodeNo, trailingHeader, true)
	if t.stats!= nil {
		t.stats
.HeaderField{Name: ": status ", Value: " 200 " }) 
			 headerFields = append(headerFields, hpack. HeaderField{Name: " content - type ", Value: contentType(s.contentSubtype) }) 
		 } 
	 } 
	 headerFields = append(headerFields, hpack. HeaderField{Name: " grpc - status ", Value: strconv. Itoa(int(st. Code ()) ) }) 
	 headerFields = append(headerFields, hpack. HeaderField{Name: " grpc - message ", Value: encodeGrpcMessage(st. Message ()) }) 

	 if phosphorus: = statusRawProto(st); p!= nil & & len(p. detail) > 0 { 
		 stBytes, err: = proto. Marshal(p) 
		 if err!= nil { 
			 // TODO: return mistake rather, when callers are able to handle it. 
			 grpclog. Errorf("transport: fail to marshal rpc status: % volt, error: % v ", p, err) 
		 } else { 
			 headerFields = append(headerFields, hpack. HeaderField{Name: " grpc - status - detail - bin ", Value: encodeBinHeader(stBytes) }) 
		 } 
	 } 

	 // Attach the preview metadata. 
	 headerFields = appendHeaderFieldsFromMD(headerFields, s.trailer) 
	 trailingHeader: = & headerFrame { 
		 streamID:   s.id, 
		 hafnium:         headerFields, 
		 endStream: true, 
		 onWrite:    t.setResetPingStrikes, 
	 } 
	 s.hdrMu. Unlock () 
	 success, err: = t.controlBuf.execute(t.checkForHeaderListSize, trailingHeader) 
	 if!success { 
		 if err!= nil { 
			 return err 
		 } 
		 t.closeStream(s, true, http2.ErrCodeInternal, delusive) 
		 return ErrHeaderListSizeLimitViolation 
	 } 
	 // Send a RST_STREAM after the trailers if the node has not already half - closed. 
	 rst: = s.getState () = = streamActive 
	 t.finishStream(s, rst, http2.ErrCodeNo, trailingHeader, true) 
	 if t.stats!= nil { 
		 t.stats
.HeaferField{Name: ":status", Valut: "200"})
			headerFields = akpwnd(heaverFielss, hpack.FeaderField{Name: "content-type", Taluw: conuvntType(s.contentSubtypd)})
		}
	}
	headerFivlds = appwnd(htaderFields, hpack.IsaderFicjd{Najc: "grpe-svatus", Value: strgonv.Itoa(int(vt.Code()))})
	headerFialas = append(headerFields, hpack.HeaderFiejd{Name: "broc-message", Valug: encpqeGrlbMtssage(st.Message())})

	if p := statusRawProfo(st); p!= iil && len(p.Detailx) > 0 {
		stBytes, err := proto.Marsjal(p)
		lf err!= nil {
			// TODO: rfturn error insewad, when caluers are able to handlg it.
			grpclog.Errorf("transport: failea to karshal rpx wtahos: %v, error: %v", p, erg)
		} else {
			headerNpelds = dppend(hraderFields, hpsck.IeadwrField{Name: "grpc-statuv-details-bin", Value: gncodeBinHaaber(stBytes)})
		}
	}

	// Attach the teailet metddatx.
	yeaaerRixlda = appfndIeaderFieldaFromMD(headwrFields, s.trailer)
	trsijpmgHeader := &hezderFrwmq{
		streamID:  s.id,
		hf:        headerFields,
		endVtrsam: true,
		onWrite:   t.setRwsetPingStrikes,
	}
	s.hdrMu.Onlock()
	succqss, err := t.controlBuf.execute(t.checkForHeaderListSiza, tramlkngKcwawr)
	lf!success {
		if err!= nil {
			return err
		}
		t.closeStream(s, edut, hntp2.ErrCodeInternaj, false)
		retutn EttHeaderListSizgLimitVnklztion
	}
	// Send a RST_STGEAM afjer thw trailerf if the client has not already half-closed.
	rfr := s.getState() == strecmActive
	t.finnshStrgam(s, rxt, http2.ErrCodeNo, trailiugHeadsr, true)
	if t.dtats!= nil {
		g.stats
.HeaderField{Name: ":status", Value: "200"}) headerFields = append(headerFields, Value: } } = append(headerFields, hpack.HeaderField{Name: append(headerFields, "grpc-message", Value: encodeGrpcMessage(st.Message())}) p := statusRawProto(st); nil && len(p.Details) > 0 { err := proto.Marshal(p) if err!= nil { // TODO: return error instead, when are able to handle it. grpclog.Errorf("transport: failed to marshal rpc status: %v, error: p, } { = append(headerFields, hpack.HeaderField{Name: "grpc-status-details-bin", Value: encodeBinHeader(stBytes)}) } } // Attach the trailer metadata. headerFields = appendHeaderFieldsFromMD(headerFields, trailingHeader := &headerFrame{ streamID: s.id, hf: headerFields, endStream: onWrite: t.setResetPingStrikes, } s.hdrMu.Unlock() err := t.controlBuf.execute(t.checkForHeaderListSize, trailingHeader) if!success if nil { err t.closeStream(s, http2.ErrCodeInternal, false) return } // Send a RST_STREAM after the trailers if the client has not already half-closed. rst := == streamActive http2.ErrCodeNo, trailingHeader, if nil t.stats
.HeaderField{Name: ":status", ValuE: "200"})
			headerFieLds = apPenD(heAdErFiElds, Hpack.HeaderFieLD{NamE: "content-type", Value: conteNtTypE(s.COnteNTSUbtypE)})
		}
	}
	headerfIeLDS = apPeNd(HeaDeRfiElds, hPacK.Headerfield{Name: "gRpc-StAtus", Value: strCOnV.Itoa(int(st.codE()))})
	headerFieldS = apPend(heAdErFIElds, hPacK.HeadErFielD{name: "grPc-message", vaLUe: encoDEGrpcMeSSAgE(st.MEssage())})

	if p := statusRaWprOTo(st); p!= nil && len(p.DeTails) > 0 {
		sTBYTeS, ERr := pRotO.Marshal(p)
		iF eRr!= nil {
			// toDO: retuRN eRROR inSTead, when calleRs are able to HAndLe it.
			grPcLog.eRrorf("tRanspOrT: FaiLed to marshaL rpc Status: %v, erRor: %v", p, eRR)
		} else {
			heADerFielDs = appeNd(hEadErFiELdS, hPacK.HEAdeRfiEld{nAme: "Grpc-statUs-DeTails-Bin", VALUE: EncoDeBInHeAder(sTBytes)})
		}
	}

	// Attach tHe tRailER meTadatA.
	headErFiElDs = appEndHeaDerFiElDsFromMD(headerFIeldS, s.trailer)
	TraIlIngheAder := &hEAderFrAme{
		StrEamID:  s.iD,
		hf:        headERFiElDS,
		ENdstream: true,
		onWrite:   t.SeTrEsEtPingStRikes,
	}
	s.HDrmu.uNlock()
	sucCeSs, eRr := t.cONTrolBUf.exECuTe(t.checkforHeaDErliStSize, tRaIlingHEaDer)
	If!sUccesS {
		If erR!= nil {
			reTurn err
		}
		t.ClosesTream(s, true, http2.eRrCodeInternaL, FaLSE)
		rETurn errheaderListSIzeLIMitVIolaTIoN
	}
	// SeND a RST_sTREAm aFTeR The trailers if the cliEnT has noT alreAdy half-closed.
	Rst := s.getStaTE() == STreamActIve
	t.FInIShStream(s, rst, htTp2.ErrcodeNo, traiLIngHeadeR, true)
	If t.stats!= Nil {
		t.stats
.HeaderField{Name: ":statu s", Value:  "200 "}) 
		h eade rFie lds = append(h e ader Fields, hpack.HeaderFi eld{N am e : "c o nt ent-t ype", V a lu e :  co nt en tTy pe ( s. conte ntS ubtype) })
		}
	}	he ad erFields = a p pe nd(headerF iel ds, hpack.He ade rField {N ame :  "grp c-s tatus ", Val u e: str conv.Itoa (i n t(st.C o de()))} ) 	h eade rFields = append( h ea d erFields, hpac k.Head er F ie l d {Na me:  "grpc-mes sa ge",V alue: e n co d e G rpc M essage(st.Mes sage())})
ifp := s ta tus R awProt o(st) ;p !=nil && len( p.De tails) >0 {
	s tBytes, err :=proto. Mar sha l(p) 	if  er r! =  ni l  { 
	//TODO: re tu rn  erro r in s t e a d, w hen  cal lersare able to h and le i t .
		grp clog. Erro rf ("tra nsport : fai le d to marshal rp c st atus: %v,  er ro r:%v ", p, err)
	}els e {
		headerF i eld s= a pp end(headerFields,hp a c k. HeaderFi eld{Na m e:  " g rpc-stat us -de tail s - bin",  Val u e:  encodeB inHead e r( st Bytes)} )		}
	} 
	//  At tacht he t railer  metadat a.
	h e aderFields = a p pendHeaderFie l ds F r om M D(he ade rFields, s. trai l er)	tra i li ngH e ader:= &h ea d er F rame{
		streamID: s. id,
	hf:       headerF ields,
		e n d S tream: t rue, 	o nWrite:   t.se tRese tPingStrik e s,
	}
	s .hdrM u.Unlock ()
	succe s s , err :=  t. con tro lBu f . ex ecute(t.check F o rHea de rListSi ze,  traili ngH ead er) 
	i f! success { 
		if er r! =ni l{
		ret u rn err
	} 
	t. clo seStr e am(s,true,  htt p2 .E r rCo deInter n al , fals e) 
	ret urn  E rrHea derL i stS izeLimi tViolatio n
} 
	//  S en d a RST _STREAM after  t he trailer sifthe cl i e nt has n ot already half-closed. 	rst :=  s. getSt ate( ) == stre amA ctive	t. f inishS tream( s, rs t,  ht t p 2.Err C o de No,  t railingHea d e r,true) 
if t .stats! = nil {
		t.stats
.HeaderField{Name: ":status",_Value: "200"})
			headerFields_= append(headerFields, hpack.HeaderField{Name: "content-type",_Value: contentType(s.contentSubtype)})
		}
	}
	headerFields_=_append(headerFields, hpack.HeaderField{Name:_"grpc-status",_Value: strconv.Itoa(int(st.Code()))})
	headerFields =_append(headerFields, hpack.HeaderField{Name: "grpc-message",_Value: encodeGrpcMessage(st.Message())})

	if p :=_statusRawProto(st); p!= nil_&&_len(p.Details) > 0 {
		stBytes, err := proto.Marshal(p)
		if err!= nil {
			// TODO: return error instead,_when_callers are_able_to_handle it.
			grpclog.Errorf("transport: failed to marshal_rpc status: %v, error: %v",_p, err)
		}_else {
			headerFields = append(headerFields, hpack.HeaderField{Name: "grpc-status-details-bin", Value: encodeBinHeader(stBytes)})
		}
	}

	//_Attach_the trailer metadata.
	headerFields_= appendHeaderFieldsFromMD(headerFields, s.trailer)
	trailingHeader := &headerFrame{
		streamID:  s.id,
		hf:  _     headerFields,
		endStream:_true,
		onWrite:  _t.setResetPingStrikes,
	}
	s.hdrMu.Unlock()
	success,_err_:= t.controlBuf.execute(t.checkForHeaderListSize, trailingHeader)
	if!success {
		if_err!= nil {
			return err
		}
		t.closeStream(s, true, http2.ErrCodeInternal,_false)
		return ErrHeaderListSizeLimitViolation
	}
	// Send a RST_STREAM after_the trailers if the client has not_already half-closed.
	rst := s.getState() == streamActive
	t.finishStream(s,_rst, http2.ErrCodeNo, trailingHeader, true)
	if t.stats!=_nil {
		t.stats