func (c *codec) ReadHeader(meta *metapb.RpcMeta) (err error) {
	// decode rpc header
	headerSize := int(unsafe.Sizeof(rpcHeader{}))
	buf, err := c.readBuffer(headerSize)
	if err != nil {
		return err
	}

	if !bytes.Equal(buf[:4], MagicStr[:]) {
		return ErrBadMagic
	}
	c.h.X.PacketSize = int32(binary.BigEndian.Uint32(buf[4:8]))
	c.h.X.MetaSize = int32(binary.BigEndian.Uint32(buf[8:12]))

	if c.h.X.PacketSize > maxMessageSize {
		return ErrBadMessageSize
	}

	// decode rpc meta
	buf, err = c.readBuffer(int(c.h.X.MetaSize))
	if err != nil {
		return err
	}
	err = proto.Unmarshal(buf, meta)
	if err != nil {
		return
	}
	if meta.GetAttachmentSize() != 0 {
		return errors.New("attachment not supported")
	}
	return
}
// ReadHeader read rpc header from peer
ReadHeader read rpc header from peer
// ReadHeader read rpc header from peer
func (c *codec) ReadHeader(meta *metapb.RpcMeta) (err error) {
	headerSize := int(unsafe.Sizeof(rpcHeader{}))
	buf, err := c.readBuffer(headerSize)
	if err != nil {
		return err
	}
	if !bytes.Equal(buf[:4], MagicStr[:]) {
		return ErrBadMagic
	}
	c.h.X.PacketSize = int32(binary.BigEndian.Uint32(buf[4:8]))
	c.h.X.MetaSize = int32(binary.BigEndian.Uint32(buf[8:12]))
	if c.h.X.PacketSize > maxMessageSize {
		return ErrBadMessageSize
	}
	buf, err = c.readBuffer(int(c.h.X.MetaSize))
	if err != nil {
		return err
	}
	err = proto.Unmarshal(buf, meta)
	if err != nil {
		return
	}
	if meta.GetAttachmentSize() != 0 {
		return errors.New("attachment not supported")
	}
	return
}
func ( c * codec ) ReadHeader ( meta * metapb . RpcMeta ) ( err error ) { headerSize := int ( unsafe . Sizeof ( rpcHeader { } ) ) buf , err := c . readBuffer ( headerSize ) if err != nil { return err } if ! bytes . Equal ( buf [ : 4 ] , MagicStr [ : ] ) { return ErrBadMagic } c . h . X . PacketSize = int32 ( binary . BigEndian . Uint32 ( buf [ 4 : 8 ] ) ) c . h . X . MetaSize = int32 ( binary . BigEndian . Uint32 ( buf [ 8 : 12 ] ) ) if c . h . X . PacketSize > maxMessageSize { return ErrBadMessageSize } buf , err = c . readBuffer ( int ( c . h . X . MetaSize ) ) if err != nil { return err } err = proto . Unmarshal ( buf , meta ) if err != nil { return } if meta . GetAttachmentSize ( ) != 0 { return errors . New ( " " ) } return }
ReadHeader read rpc header from peer
ReadHeader read rpc header from peer
// decode rpc header // decode rpc meta