Skip to content

Commit

Permalink
fix[csharp]: The Deserialize should use the ClientUtils to handle the…
Browse files Browse the repository at this point in the history
… headers. (#16604)
  • Loading branch information
fghpdf authored Nov 18, 2023
1 parent 8258cde commit a577db8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,18 @@ namespace {{packageName}}.Client
/// <returns>Object representation of the JSON string.</returns>
internal async Task<object> Deserialize(HttpResponseMessage response, Type type)
{
IList<string> headers = response.Headers.Select(x => x.Key + "=" + x.Value).ToList();
IList<string> headers = new List<string>();
// process response headers, e.g. Access-Control-Allow-Methods
foreach (var responseHeader in response.Headers)
{
headers.Add(responseHeader.Key + "=" + ClientUtils.ParameterToString(responseHeader.Value));
}

// process response content headers, e.g. Content-Type
foreach (var responseHeader in response.Content.Headers)
{
headers.Add(responseHeader.Key + "=" + ClientUtils.ParameterToString(responseHeader.Value));
}

if (type == typeof(byte[])) // return byte array
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,18 @@ public async Task<T> Deserialize<T>(HttpResponseMessage response)
/// <returns>Object representation of the JSON string.</returns>
internal async Task<object> Deserialize(HttpResponseMessage response, Type type)
{
IList<string> headers = response.Headers.Select(x => x.Key + "=" + x.Value).ToList();
IList<string> headers = new List<string>();
// process response headers, e.g. Access-Control-Allow-Methods
foreach (var responseHeader in response.Headers)
{
headers.Add(responseHeader.Key + "=" + ClientUtils.ParameterToString(responseHeader.Value));
}

// process response content headers, e.g. Content-Type
foreach (var responseHeader in response.Content.Headers)
{
headers.Add(responseHeader.Key + "=" + ClientUtils.ParameterToString(responseHeader.Value));
}

if (type == typeof(byte[])) // return byte array
{
Expand Down

0 comments on commit a577db8

Please sign in to comment.