Tweaks based on analyzers
Signed-off-by: James Thompson <thompson.tomo@outlook.com>
This commit is contained in:
parent
0178d262ab
commit
af662ecdef
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) Cloud Native Foundation.
|
// Copyright (c) Cloud Native Foundation.
|
||||||
// Licensed under the Apache 2.0 license.
|
// Licensed under the Apache 2.0 license.
|
||||||
// See LICENSE file in the project root for full license information.
|
// See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
@ -94,11 +94,12 @@ namespace CloudNative.CloudEvents.AspNetCore
|
||||||
foreach (var header in headers)
|
foreach (var header in headers)
|
||||||
{
|
{
|
||||||
string? attributeName = HttpUtilities.GetAttributeNameFromHeaderName(header.Key);
|
string? attributeName = HttpUtilities.GetAttributeNameFromHeaderName(header.Key);
|
||||||
if (attributeName is null || attributeName == CloudEventsSpecVersion.SpecVersionAttribute.Name)
|
string? headerValue = header.Value.First();
|
||||||
|
if (attributeName is null || attributeName == CloudEventsSpecVersion.SpecVersionAttribute.Name || headerValue is null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
string attributeValue = HttpUtilities.DecodeHeaderValue(header.Value.First());
|
string attributeValue = HttpUtilities.DecodeHeaderValue(headerValue);
|
||||||
|
|
||||||
cloudEvent.SetAttributeFromString(attributeName, attributeValue);
|
cloudEvent.SetAttributeFromString(attributeName, attributeValue);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) Cloud Native Foundation.
|
// Copyright (c) Cloud Native Foundation.
|
||||||
// Licensed under the Apache 2.0 license.
|
// Licensed under the Apache 2.0 license.
|
||||||
// See LICENSE file in the project root for full license information.
|
// See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ namespace CloudNative.CloudEvents.AspNetCore
|
||||||
// Map headers in either mode.
|
// Map headers in either mode.
|
||||||
// Including the headers in structured mode is optional in the spec (as they're already within the body) but
|
// Including the headers in structured mode is optional in the spec (as they're already within the body) but
|
||||||
// can be useful.
|
// can be useful.
|
||||||
destination.Headers.Add(HttpUtilities.SpecVersionHttpHeader, HttpUtilities.EncodeHeaderValue(cloudEvent.SpecVersion.VersionId));
|
destination.Headers.Append(HttpUtilities.SpecVersionHttpHeader, HttpUtilities.EncodeHeaderValue(cloudEvent.SpecVersion.VersionId));
|
||||||
foreach (var attributeAndValue in cloudEvent.GetPopulatedAttributes())
|
foreach (var attributeAndValue in cloudEvent.GetPopulatedAttributes())
|
||||||
{
|
{
|
||||||
var attribute = attributeAndValue.Key;
|
var attribute = attributeAndValue.Key;
|
||||||
|
@ -67,7 +67,7 @@ namespace CloudNative.CloudEvents.AspNetCore
|
||||||
if (attribute != cloudEvent.SpecVersion.DataContentTypeAttribute)
|
if (attribute != cloudEvent.SpecVersion.DataContentTypeAttribute)
|
||||||
{
|
{
|
||||||
string headerValue = HttpUtilities.EncodeHeaderValue(attribute.Format(value));
|
string headerValue = HttpUtilities.EncodeHeaderValue(attribute.Format(value));
|
||||||
destination.Headers.Add(HttpUtilities.HttpHeaderPrefix + attribute.Name, headerValue);
|
destination.Headers.Append(HttpUtilities.HttpHeaderPrefix + attribute.Name, headerValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue