diff --git a/src/NATS.Client.Core/NatsHeaders.cs b/src/NATS.Client.Core/NatsHeaders.cs index f7bec3f67..3dcf429b6 100644 --- a/src/NATS.Client.Core/NatsHeaders.cs +++ b/src/NATS.Client.Core/NatsHeaders.cs @@ -294,6 +294,16 @@ public void CopyTo(KeyValuePair[] array, int arrayIndex) } } + /// + /// Returns the bytes length of the header + /// + /// an instance of headerWriter + /// bytes length of th header + public long GetBytesLength(HeaderWriter headerWriter) + { + return headerWriter.GetBytesLength(this); + } + /// /// Removes the given item from the the collection. /// diff --git a/tests/NATS.Client.CoreUnit.Tests/NatsHeaderTest.cs b/tests/NATS.Client.CoreUnit.Tests/NatsHeaderTest.cs index 523dd7e18..a918a79de 100644 --- a/tests/NATS.Client.CoreUnit.Tests/NatsHeaderTest.cs +++ b/tests/NATS.Client.CoreUnit.Tests/NatsHeaderTest.cs @@ -207,7 +207,7 @@ public void GetBytesLengthTest() ["key"] = "a-long-header-value", }; var writer = new HeaderWriter(Encoding.UTF8); - var bytesLength = writer.GetBytesLength(headers); + var bytesLength = headers.GetBytesLength(writer); var text = "NATS/1.0\r\nk1: v1\r\nk2: v2-0\r\nk2: v2-1\r\na-long-header-key: value\r\nkey: a-long-header-value\r\n\r\n"; var expected = new ReadOnlySequence(Encoding.UTF8.GetBytes(text));