(data io.Reader)
| 119 | } |
| 120 | |
| 121 | func parseHighwayPacket(data io.Reader) (head *highway.RespDataHighwayHead, body *binary.Reader, err error) { |
| 122 | reader := binary.ParseReader(data) |
| 123 | if reader.ReadBytesNoCopy(1)[0] != 0x28 { |
| 124 | return nil, nil, errors.New("invalid highway packet") |
| 125 | } |
| 126 | headlength := reader.ReadU32() |
| 127 | _ = reader.ReadU32() // body len |
| 128 | head = &highway.RespDataHighwayHead{} |
| 129 | headraw := reader.ReadBytesNoCopy(int(int64(headlength))) |
| 130 | err = proto.Unmarshal(headraw, head) |
| 131 | if err != nil { |
| 132 | return nil, nil, err |
| 133 | } |
| 134 | if reader.ReadBytesNoCopy(1)[0] != 0x29 { |
| 135 | return nil, nil, errors.New("invalid highway head") |
| 136 | } |
| 137 | return head, reader, nil |
| 138 | } |
| 139 | |
| 140 | func sendHighwayPacket(packet *highway.ReqDataHighwayHead, block []byte, serverURL string, end bool) (io.ReadCloser, error) { |
| 141 | marshal, err := proto.Marshal(packet) |
no test coverage detected