Exposing response headers through a generated C# client
See original GitHub issuePreface: I want to implement the ETag header for some of my resources. My initial plan is to use [SwaggerResponse(HttpStatusCode.NotModified, typeof(void))]
and handle ETag logic inside the action.
For the above to work, I need to be able to read the response headers with my generated clients, to extract the current ETag. I’m not quite sure how this can be achieved without breaking existing code. Perhaps a new generator setting can be added, to have methods return value tuples containing the response headers. So instead of
Task<Foo> Foos_GetFooAsync(int id)
it generates
Task<(Foo value, HttpResponseHeaders responseHeaders)> Foos_GetFooAsync(int id)
Then you can either use the headers
(var foo, var headers) = await Foos_GetFooAsync(id)
or discard them
(var foo, _) = await Foos_GetFooAsync(id)
Do you think this is a path worth exploring? Or do you have something else in mind? I can help out with implementing this if you like.
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
Exposing response headers through a generated C# client
Preface: I want to implement the ETag header for some of my resources. My initial plan is to use [SwaggerResponse(HttpStatusCode.
Read more >How do I expose a WCF web service call response header ...
My problem is that I want to expose the actual HTTP header received in the above call, such as client.GetHttpResponse() or something.
Read more >Access-Control-Expose-Headers - HTTP - MDN Web Docs
The Access-Control-Expose-Headers response header allows a server to indicate which response headers should be made available to scripts ...
Read more >HTTP Security Response Headers Cheat Sheet
Proper HTTP response headers can help prevent security vulnerabilities like Cross-Site Scripting, Clickjacking, Information disclosure and more. In this cheat ...
Read more >Response Header - an overview
Most actionable response headers are generated by the Web server itself. These include instructions for the client to cache the content (or not), ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ah, thank you. The client name is
Client
in this case, soClient.Workspaces_Head
made it work.I think it’s clientName.methodName