Inconsistent `user-agent` header between `fetch-to-curl` output and actual from node-fetch
zdanowiczkonrad opened this issue · comments
I distinguished one discrepancy while comparing the actual payloads using Wireshark - user-agent
sent to the remote server will be different if executed a request via node-fetch
and then via curl
from the payload generated by this library.
Repro:
- Start capturing HTTP traffic using ie. Wireshark
- Execute a GET request using
node-fetch
- Copy the cURL returned by
fetch-to-curl
- Execute this exact request via cURL
- Compare
user-agent
headers
Comparing actual payloads reveal that the node-fetch
has a header user-agent: node-fetch
, while fetch-to-curl
returns a curl without explicit user-agent
header, hence the default one is sent - user-agent: curl/<curl version>
.
Not sure if that's by design or you aim to return an identical request from the transfer layer perspective - if the latter - we may consider adding a hardcoded user-agent
if not specified explicitly to the node-fetch
via request options.
There are also other small inconsistencies that may be worth unifying.
Hi @zdanowiczkonrad thanks for the report. The different user agent I'd consider as an incosistency by design.
However for the use case where a log on an end user device (react-native app or similar) is written, which can than be sent as debugging information to the developer, it might be really useful to know the original user agent as well. (For my end user logging use cases this is not an issue since the bundle of debug information includes the device information as well.)
I'll keep the issue open to see if there is a need to add the original user agent of the request for others.
Out of curiosity: What other small inconsistencies did you notice?
hi @leoek! Makes sense to me, feel free to keep this one open as long as you think it is relevant!
I don't remember now what exactly wasn't 100% consistent when comparing the transport, but I recall it was about default request headers sent/not-sent. But now cannot remember the specifics.
Closing this since there were no further inconsistencies found within 6+ months.