Setting headers with "HTTP Response" node

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:

   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?

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

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:

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

Thanks, I'll give it a try.

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