MCPcopy
hub / github.com/TarsCloud/TarsGo / rsp2Byte

Method rsp2Byte

tars/tarsprotocol.go:177–190  ·  view source on GitHub ↗
(rsp *requestf.ResponsePacket)

Source from the content-addressed store, hash-verified

175}
176
177func (s *Protocol) rsp2Byte(rsp *requestf.ResponsePacket) []byte {
178 if rsp.IVersion == basef.TUPVERSION {
179 return s.req2Byte(rsp)
180 }
181 os := codec.NewBuffer()
182 rsp.WriteTo(os)
183 bs := os.ToBytes()
184 sbuf := bytes.NewBuffer(nil)
185 sbuf.Write(make([]byte, 4))
186 sbuf.Write(bs)
187 length := sbuf.Len()
188 binary.BigEndian.PutUint32(sbuf.Bytes(), uint32(length))
189 return sbuf.Bytes()
190}
191
192// ParsePackage parse the []byte according to the tars protocol.
193// returns header length and package integrity condition (PackageLess | PackageFull | PackageError)

Callers 3

InvokeMethod · 0.95
InvokeTimeoutMethod · 0.95
GetCloseMsgMethod · 0.95

Calls 6

req2ByteMethod · 0.95
ToBytesMethod · 0.95
LenMethod · 0.95
NewBufferFunction · 0.92
WriteMethod · 0.65
WriteToMethod · 0.45

Tested by

no test coverage detected