As I understand it, when you build an HTTP response in node / express or something else, the process consists primarily of two inconsistent steps: defining the headers and building the body. Headers include Set-Cookie headers. In Express, the following methods are available for the response object for setting headers:
res.append(); // To append/create headers res.cookie(); // A convenience method to append set-cookie headers.
Since the headers are only buffered and not actually sent until the response is sent, is there any method or mechanism for getting the current list of header sets along with their values, for example:
headers = res.getHeaders(); //Returns an object with headers and values headers = res.getHeaders('Set-Cookie'); // To get only select headers
source share