Skip to content

Commit 5f74993

Browse files
committed
Adding response headers to the generic RestResponse object
1 parent b50a9b3 commit 5f74993

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

generator/cybersource-csharp-template/ApiClient.mustache

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,6 @@ namespace {{packageName}}.Client
373373
{{/supportsUWP}}
374374
{{/netStandard}}
375375
InterceptResponse(request, response);
376-
377-
Configuration.DefaultHeader.Clear();
378-
379-
httpResponseStatusCode = (int)response.StatusCode;
380-
httpResponseHeaders = response.Headers;
381-
httpResponseData = response.Content;
382376
}
383377
{
384378
//setting file name
@@ -406,16 +400,12 @@ namespace {{packageName}}.Client
406400
}
407401
}
408402

409-
httpResponseStatusCode = (int)responseT.StatusCode;
410-
httpResponseHeaders = new List<Parameter>();
403+
//setting the generic response with response headers
411404
foreach (var header in responseT.Headers)
412405
{
413-
string[] headerValue = responseT.Headers.GetValues(header.ToString());
414-
httpResponseHeaders.Add(new Parameter(header.ToString(), String.Join(",", headerValue.ToArray()), ParameterType.HttpHeader));
406+
response.Headers.Add(new Parameter(header.ToString(), String.Join(",", responseT.Headers.GetValues(header.ToString()).ToArray()), ParameterType.HttpHeader));
415407
}
416408

417-
httpResponseData = "Custom Message: Response downloaded to file " + downloadReponseFileName;
418-
419409
//setting the generic RestResponse which is returned to the calling class
420410
response.StatusCode = responseT.StatusCode;
421411
if (responseT.StatusCode == HttpStatusCode.OK)
@@ -432,6 +422,12 @@ namespace {{packageName}}.Client
432422
}
433423
}
434424

425+
Configuration.DefaultHeader.Clear();
426+
427+
httpResponseStatusCode = (int)response.StatusCode;
428+
httpResponseHeaders = response.Headers;
429+
httpResponseData = response.Content;
430+
435431
Console.WriteLine($"\n");
436432
Console.WriteLine($"RESPONSE STATUS CODE: {httpResponseStatusCode}");
437433

0 commit comments

Comments
 (0)