2 // Copyright © 2011-2019 Guy M. Allard
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
24 Size returns the size of Frame on the wire, in bytes.
26 func (f
*Frame
) Size(e
bool) int64 {
28 r
+= int64(len(f
.Command
)) + 1 + f
.Headers
.Size(e
) + 1 + int64(len(f
.Body
)) + 1
33 Bytes returns a byte slice of all frame data, ready for the wire
35 func (f
*Frame
) Bytes(sclok
bool) []byte {
36 b
:= make([]byte, 0, 8*1024)
37 b
= append(b
, f
.Command
+"\n"...)
38 hb
:= f
.Headers
.Bytes()
42 b
= append(b
, "\n"...)
45 nz
:= bytes
.IndexByte(f
.Body
, 0)
46 // fmt.Printf("WDBG41 ok:%v\n", nz)
49 // fmt.Printf("WDBG42 body:%v bodystring: %v\n", f.Body, string(f.Body))
52 // fmt.Printf("WDBG43 body:%v bodystring: %v\n", f.Body, string(f.Body))
56 b
= append(b
, f
.Body
...)