From 4f73bb1a3cb4c46b944a3a1b65138035a2779836 Mon Sep 17 00:00:00 2001 From: William Hilton Date: Fri, 1 Jun 2018 16:47:30 -0400 Subject: [PATCH] Allow setting User-Agent Header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The User-Agent header has not been forbidden since Firefox 43 (see https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name). > Note: The User-Agent header is no longer forbidden, as per spec — see forbidden header name list (this was implemented in Firefox 43) — it can now be set in a Fetch Headers object, or via XHR setRequestHeader(). I've had success setting it in Firefox and Edge for `fetch` and it should work for XMLHttpRequest as well but I'm too lazy to look up how to use XMLHttpRequest. I haven't had any luck setting User-Agent it in Chrome yet - may be a Chrome bug - but I'm not seeing any warnings in the terminal when I use it either, so I don't think allowing it will cause any spurious warnings. --- lib/request.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/request.js b/lib/request.js index fcd533b..4f097df 100644 --- a/lib/request.js +++ b/lib/request.js @@ -323,6 +323,5 @@ var unsafeHeaders = [ 'trailer', 'transfer-encoding', 'upgrade', - 'user-agent', 'via' ]