Currently, both headers supplied to a request and headers received from the response are found under the same key headers in the msg object. This can easily give rise to hard-to-find bugs in the following situation:
… --> [set headers] --> [request 1] --> [request 2] --> …
First, headers are set (msg.headers = {…}). Then, after request 1, msg.headers now contains the response headers of request 1. When request 2 is made, these are supplied as request headers. You need to clear the headers between the requests:
… --> [set headers] --> [request 1] --> {msg.headers = {}} --> [request 2] --> …
I guess this is useful when piping the output of one request directly into another, since the content-type, content-length etc headers will be appropriately set automatically. Still, it's easily overlooked and the result can be very unexpected.
Suggestion:
Maybe the headers could be stored under different keys, such as msg.requestHeaders and msg.responseHeaders? Then requestHeaders can be cleared automatically by each request since they aren't needed anymore.
Currently, both headers supplied to a request and headers received from the response are found under the same key
headersin themsgobject. This can easily give rise to hard-to-find bugs in the following situation:First, headers are set (
msg.headers = {…}). Then, after request 1,msg.headersnow contains the response headers of request 1. When request 2 is made, these are supplied as request headers. You need to clear the headers between the requests:I guess this is useful when piping the output of one request directly into another, since the
content-type,content-lengthetc headers will be appropriately set automatically. Still, it's easily overlooked and the result can be very unexpected.Suggestion:
Maybe the headers could be stored under different keys, such as
msg.requestHeadersandmsg.responseHeaders? ThenrequestHeaderscan be cleared automatically by each request since they aren't needed anymore.