Bug 1642201 - Remove undefined and trim the headers for edit & resend. r=Honza, a=jcristau
authorHubert Boma Manilla <hmanilla@mozilla.com>
Mon, 01 Jun 2020 07:43:37 +0000
changeset 596948 a81711950f481af92cb735ed53aa05b364bde48d
parent 596947 ebb62d9da97a514ff3e301c453114d304b9137b7
child 596949 cf1cee074da0714d577339f4a272412f350f0e0a
push id13215
push userjcristau@mozilla.com
push dateThu, 04 Jun 2020 13:33:19 +0000
treeherdermozilla-beta@d6fc47eb7f3b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza, jcristau
bugs1642201
milestone78.0
Bug 1642201 - Remove undefined and trim the headers for edit & resend. r=Honza, a=jcristau Differential Revision: https://phabricator.services.mozilla.com/D77617
devtools/client/netmonitor/src/components/CustomRequestPanel.js
devtools/client/netmonitor/src/utils/request-utils.js
--- a/devtools/client/netmonitor/src/components/CustomRequestPanel.js
+++ b/devtools/client/netmonitor/src/components/CustomRequestPanel.js
@@ -201,17 +201,17 @@ class CustomRequestPanel extends Compone
       requestPostData,
       url,
     } = request;
 
     let headers = "";
     if (requestHeaders) {
       headers = requestHeaders.customHeadersValue
         ? requestHeaders.customHeadersValue
-        : writeHeaderText(requestHeaders.headers);
+        : writeHeaderText(requestHeaders.headers).trim();
     }
     const queryArray = url ? parseQueryString(getUrlQuery(url)) : [];
     let params = customQueryValue;
     if (!params) {
       params = queryArray
         ? queryArray.map(({ name, value }) => name + "=" + value).join("\n")
         : "";
     }
--- a/devtools/client/netmonitor/src/utils/request-utils.js
+++ b/devtools/client/netmonitor/src/utils/request-utils.js
@@ -128,17 +128,17 @@ function formDataURI(mimeType, encoding,
  * Write out a list of headers into a chunk of text
  *
  * @param {array} headers - array of headers info { name, value }
  * @param {string} preHeaderText - first line of the headers request/response
  * @return {string} list of headers in text format
  */
 function writeHeaderText(headers, preHeaderText) {
   let result = "";
-  if (preHeaderText != "") {
+  if (preHeaderText) {
     result += preHeaderText + "\r\n";
   }
   result += headers.map(({ name, value }) => name + ": " + value).join("\r\n");
   result += "\r\n\r\n";
   return result;
 }
 
 /**