fix[csharp]: The Deserialize should use the ClientUtils to handle the headers. (#16604)

This commit is contained in:
Xiangxuan Qu 2023-11-18 15:41:17 +09:00 committed by GitHub
parent 8258cde110
commit a577db895c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 2 deletions

View File

@ -91,7 +91,18 @@ namespace {{packageName}}.Client
/// <returns>Object representation of the JSON string.</returns> /// <returns>Object representation of the JSON string.</returns>
internal async Task<object> Deserialize(HttpResponseMessage response, Type type) 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 if (type == typeof(byte[])) // return byte array
{ {

View File

@ -94,7 +94,18 @@ namespace Org.OpenAPITools.Client
/// <returns>Object representation of the JSON string.</returns> /// <returns>Object representation of the JSON string.</returns>
internal async Task<object> Deserialize(HttpResponseMessage response, Type type) 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 if (type == typeof(byte[])) // return byte array
{ {