func (h *ExtendedHeader) Write(b *bytes.Buffer, ver protocol.VersionNumber) error {
	if h.IsLongHeader {
		return h.writeLongHeader(b, ver)
	}
	return h.writeShortHeader(b, ver)
}
Write writes the Header.
package wire
import (
	"bytes"
	"errors"
	"fmt"
	"io"
	"github.com/lucas-clemente/quic-go/internal/protocol"
	"github.com/lucas-clemente/quic-go/internal/utils"
)
type ExtendedHeader struct {
	Header
	typeByte byte
	PacketNumberLen protocol.PacketNumberLen
	PacketNumber    protocol.PacketNumber
	KeyPhase int
}
func (h *ExtendedHeader) parse(b *bytes.Reader, v protocol.VersionNumber) (*ExtendedHeader, error) {
	var err error
	h.typeByte, err = b.ReadByte()
	if err != nil {
		return nil, err
	}
	if _, err := b.Seek(int64(h.ParsedLen())-1, io.SeekCurrent); err != nil {
		return nil, err
	}
	if h.IsLongHeader {
		return h.parseLongHeader(b, v)
	}
	return h.parseShortHeader(b, v)
}
func (h *ExtendedHeader) parseLongHeader(b *bytes.Reader, v protocol.VersionNumber) (*ExtendedHeader, error) {
	if h.typeByte&0xc != 0 {
		return nil, errors.New("5th and 6th bit must be 0")
	}
	if err := h.readPacketNumber(b); err != nil {
		return nil, err
	}
	return h, nil
}
func (h *ExtendedHeader) parseShortHeader(b *bytes.Reader, v protocol.VersionNumber) (*ExtendedHeader, error) {
	if h.typeByte&0x18 != 0 {
		return nil, errors.New("4th and 5th bit must be 0")
	}
	h.KeyPhase = int(h.typeByte&0x4) >> 2
	if err := h.readPacketNumber(b); err != nil {
		return nil, err
	}
	return h, nil
}
func (h *ExtendedHeader) readPacketNumber(b *bytes.Reader) error {
	h.PacketNumberLen = protocol.PacketNumberLen(h.typeByte&0x3) + 1
	pn, err := utils.BigEndian.ReadUintN(b, uint8(h.PacketNumberLen))
	if err != nil {
		return err
	}
	h.PacketNumber = protocol.PacketNumber(pn)
	return nil
}