Bug 1402828 - Improve "copy as cURL". r=Honza
☠☠ backed out by d563998a63ff ☠ ☠
authorDaniel Stenberg <daniel@haxx.se>
Fri, 29 Sep 2017 02:57:00 -0400
changeset 436285 4d059e20a773dc661f0d2fd45d2118230398f720
parent 436284 64e81f8547bb60904e728d19c4bc28c9370c0575
child 436286 161226f14afd0c9d5a3c982b0a900dd0f011cfba
push id117
push userfmarier@mozilla.com
push dateTue, 28 Nov 2017 20:17:16 +0000
reviewersHonza
bugs1402828
milestone59.0a1
Bug 1402828 - Improve "copy as cURL". r=Honza
devtools/client/shared/curl.js
--- a/devtools/client/shared/curl.js
+++ b/devtools/client/shared/curl.js
@@ -83,30 +83,30 @@ const Curl = {
     } else if (multipartRequest) {
       postDataText = data.postDataText;
       postData.push("--data-binary");
       let boundary = utils.getMultipartBoundary(data);
       let text = utils.removeBinaryDataFromMultipartText(postDataText, boundary);
       postData.push(escapeString(text));
       ignoredHeaders.add("content-length");
     }
-
-    // Add method.
-    // For GET and POST requests this is not necessary as GET is the
-    // default. If --data or --binary is added POST is the default.
-    if (!(data.method == "GET" || data.method == "POST")) {
-      command.push("-X");
-      command.push(data.method);
-    }
+    // curl generates the host header itself based on the given URL
+    ignoredHeaders.add("host");
 
     // Add -I (HEAD)
     // For servers that supports HEAD.
     // This will fetch the header of a document only.
     if (data.method == "HEAD") {
       command.push("-I");
+    } else if (!(data.method == "GET" || data.method == "POST")) {
+      // Add method.
+      // For HEAD, GET and POST requests this is not necessary. GET is the
+      // default, if --data or --binary is added POST is used, -I implies HEAD.
+      command.push("-X");
+      command.push(data.method);
     }
 
     // Add request headers.
     let headers = data.headers;
     if (multipartRequest) {
       let multipartHeaders = utils.getHeadersFromMultipartText(postDataText);
       headers = headers.concat(multipartHeaders);
     }