private static void AssertHeadersProxy(IHeaders headersProxy) { headersProxy.Should().NotBeNull(); headersProxy.Add("key", Encoding.UTF8.GetBytes("value")); headersProxy.TryGetLastBytes("key", out var headerValue).Should().BeTrue(); Encoding.UTF8.GetString(headerValue).Should().Be("value"); }
public IEnumerable <string> GetValues(string name) { // This only returns the _last_ bytes. Accessing other values is more expensive and should generally be unneccessary if (_headers.TryGetLastBytes(name, out var bytes)) { try { return(new[] { Encoding.UTF8.GetString(bytes) }); } catch (Exception ex) { Logger.Information(ex, "Could not deserialize Kafka header {headerName}", name); } } return(Enumerable.Empty <string>()); }