diff --git a/modules/openapi-generator/src/main/resources/csharp/libraries/httpclient/ApiClient.mustache b/modules/openapi-generator/src/main/resources/csharp/libraries/httpclient/ApiClient.mustache index 021fcb79a383..22993e54336c 100644 --- a/modules/openapi-generator/src/main/resources/csharp/libraries/httpclient/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/csharp/libraries/httpclient/ApiClient.mustache @@ -91,7 +91,18 @@ namespace {{packageName}}.Client /// Object representation of the JSON string. internal async Task Deserialize(HttpResponseMessage response, Type type) { - IList headers = response.Headers.Select(x => x.Key + "=" + x.Value).ToList(); + IList headers = new List(); + // 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 { diff --git a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiClient.cs b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiClient.cs index f6e3372563a8..b814e218a612 100644 --- a/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiClient.cs +++ b/samples/client/petstore/csharp/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiClient.cs @@ -94,7 +94,18 @@ public async Task Deserialize(HttpResponseMessage response) /// Object representation of the JSON string. internal async Task Deserialize(HttpResponseMessage response, Type type) { - IList headers = response.Headers.Select(x => x.Key + "=" + x.Value).ToList(); + IList headers = new List(); + // 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 {