How can you set HTTP headers in the response object when using the http module?
- response.headers = {...}
- response.setHeader(name, value)
- response.setHeaders({...})
- response.addHeader(name, value)
To set HTTP headers in the response object when using the http module, you should use response.setHeader(name, value). This method allows you to set individual headers with their corresponding values. The other options are not valid methods for setting headers.
Loading...
Related Quiz
- In Pug, to extend a layout, you use the extends keyword and to fill a block within the layout, you use the ______ keyword.
- In Node.js, the process.on('exit', handler) event listener can only perform synchronous operations and cannot perform __________.
- You are optimizing the performance of a web application that uses EJS for rendering views. The views have a lot of dynamic content and are currently slow to render. How would you approach optimizing the rendering performance of the EJS templates?
- A JavaScript file that uses export is considered a ________.
- Why is it advantageous to use stubbing when dealing with external services or APIs in tests?