# Setting headers with "HTTP Response" node

**URL:** <https://discourse.nodered.org/t/setting-headers-with-http-response-node/30719>\
**Category:** General\
**Created:** [26 July 2020 10:14 UTC](https://discourse.nodered.org/t/setting-headers-with-http-response-node/30719 "2020-07-26T10:14:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![augjoh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/augjoh/32/26464_2.png) [@augjoh](https://discourse.nodered.org/u/augjoh)\
**Post date:** [26 July 2020 10:14 UTC](https://discourse.nodered.org/t/setting-headers-with-http-response-node/30719/1 "2020-07-26T10:14:16Z")

</div>

Our project aims to implement ACMEv2 (RFC8555). This RFC requires to set multiple HTTP-headers with the same key (Link:) value. The following example is taken from RFC8555 7.1.2.1:

```auto
   HTTP/1.1 200 OK
   Content-Type: application/json
   Link: <https://example.com/acme/directory>;rel="index"
   Link: <https://example.com/acme/orders/rzGoeA?cursor=2>;rel="next"

   {
     "orders": [
       "https://example.com/acme/order/TOlocE8rfgo",
       "https://example.com/acme/order/4E16bbL5iSw",
       /* more URLs not shown for example brevity */
       "https://example.com/acme/order/neBHYLfw0mg"
     ]
   }

```

How can this behaviour achieved using the `HTTP Response` node?

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [26 July 2020 11:07 UTC](https://discourse.nodered.org/t/setting-headers-with-http-response-node/30719/2 "2020-07-26T11:07:45Z")

</div>

You can set response headers via a function node. For `Link`, use an array:

```auto
msg.headers = {}
msg.headers['Content-type'] = "application/json"
msg.headers['Link'] = ["https://example.com/acme/directory>;rel='index'","https://example.com/acme/orders/rzGoeA?cursor=2>;rel='next'"]
return msg

```

Example output:

```auto
curl -v "10.0.0.6:1880/headertest"
* Trying 10.0.0.6...
* TCP_NODELAY set
* Connected to 10.0.0.6 (10.0.0.6) port 1880 (#0)
> GET /headertest HTTP/1.1
> Host: 10.0.0.6:1880
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 200 OK
< X-Powered-By: Express
< Access-Control-Allow-Origin: *
< Content-Type: application/json; charset=utf-8
< Link: https://example.com/acme/directory>;rel='index'
< Link: https://example.com/acme/orders/rzGoeA?cursor=2>;rel='next'
< Content-Length: 2
< ETag: W/"2-vyGp6PvFo4RvsFtPoIWeCReyIC8"
< Vary: Accept-Encoding
< Date: Sun, 26 Jul 2020 11:06:27 GMT
< Connection: keep-alive

```

---

<div class="post-metadata">

**Author:** ![augjoh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/augjoh/32/26464_2.png) [@augjoh](https://discourse.nodered.org/u/augjoh)\
**Post date:** [26 July 2020 11:37 UTC](https://discourse.nodered.org/t/setting-headers-with-http-response-node/30719/3 "2020-07-26T11:37:12Z")

</div>

Thanks, I'll give it a try.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [24 September 2020 11:37 UTC](https://discourse.nodered.org/t/setting-headers-with-http-response-node/30719/4 "2020-09-24T11:37:20Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
