mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 04:37:36 +03:00
refactor header writing to append to a byte slice (#3646)
This avoids having to allocate a bytes.Buffer.
This commit is contained in:
parent
3d4bbc28ba
commit
c24fbb094c
18 changed files with 282 additions and 279 deletions
|
@ -28,7 +28,6 @@ func isProxyRunning() bool {
|
|||
|
||||
var _ = Describe("QUIC Proxy", func() {
|
||||
makePacket := func(p protocol.PacketNumber, payload []byte) []byte {
|
||||
b := &bytes.Buffer{}
|
||||
hdr := wire.ExtendedHeader{
|
||||
Header: wire.Header{
|
||||
Type: protocol.PacketTypeInitial,
|
||||
|
@ -40,10 +39,10 @@ var _ = Describe("QUIC Proxy", func() {
|
|||
PacketNumber: p,
|
||||
PacketNumberLen: protocol.PacketNumberLen4,
|
||||
}
|
||||
Expect(hdr.Write(b, protocol.VersionWhatever)).To(Succeed())
|
||||
raw := b.Bytes()
|
||||
raw = append(raw, payload...)
|
||||
return raw
|
||||
b, err := hdr.Append(nil, protocol.Version1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
b = append(b, payload...)
|
||||
return b
|
||||
}
|
||||
|
||||
readPacketNumber := func(b []byte) protocol.PacketNumber {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue