From dev-return-14932-archive-asf-public=cust-asf.ponee.io@jmeter.apache.org Sun Aug 2 07:34:25 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mailroute1-lw-us.apache.org (mailroute1-lw-us.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with ESMTPS id A6375180644 for ; Sun, 2 Aug 2020 09:34:25 +0200 (CEST) Received: from mail.apache.org (localhost [127.0.0.1]) by mailroute1-lw-us.apache.org (ASF Mail Server at mailroute1-lw-us.apache.org) with SMTP id CFA56124A65 for ; Sun, 2 Aug 2020 07:34:24 +0000 (UTC) Received: (qmail 59940 invoked by uid 500); 2 Aug 2020 07:34:24 -0000 Mailing-List: contact dev-help@jmeter.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jmeter.apache.org Delivered-To: mailing list dev@jmeter.apache.org Received: (qmail 59928 invoked by uid 99); 2 Aug 2020 07:34:23 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 Aug 2020 07:34:23 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id E531A1A40AD for ; Sun, 2 Aug 2020 07:34:22 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.202 X-Spam-Level: X-Spam-Status: No, score=-0.202 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=internetallee.de Received: from mx1-he-de.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id Y_DqyAZbj0pc for ; Sun, 2 Aug 2020 07:34:17 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=81.169.162.220; helo=internetallee.de; envelope-from=felix.schumacher@internetallee.de; receiver= Received: from internetallee.de (internetallee.de [81.169.162.220]) by mx1-he-de.apache.org (ASF Mail Server at mx1-he-de.apache.org) with ESMTPS id 9341C7F875 for ; Sun, 2 Aug 2020 07:34:16 +0000 (UTC) Received: from sunny-felix.fritz.box (unknown [88.130.181.36]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by internetallee.de (Postfix) with ESMTPSA id DDE9114021364 for ; Sun, 2 Aug 2020 09:34:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=internetallee.de; s=202007; t=1596353656; bh=QhffEHs01Db6hEMU6hyfV9yZphwy01TprP78gazcxOY=; h=Date:In-Reply-To:References:Subject:To:From:from; b=qomG6vXepm+JDqt1W5fbunF5RPzNbC7MI666y9c74A6umMrIh4OY7FhpBsM/4jvvY hgs/WScqLqOq5DFZvmZltL5nZxTkfdlA1v7b60wpPRLudWNGNF+Y4T1kABrTEBE1Sd AVHQ53R9io3StTfCfTm7o5asttUWpbcwMaz4Pzy5t6Di/5CEbW9nn1+dF0ZHey8739 O79WUyEnIfktsXDrbW5QKyZIHJvs0etPfllmK13SAbCTmx+RKftn9tdEPmeemTejKb C3qiwS/e7ZbjE7DdZMCHekk6Af76lwk/WAPNQq821HIRPifloi/TJe+Do265fiGU7Z c9yQPxOmUKf1g== Date: Sun, 02 Aug 2020 09:34:13 +0200 User-Agent: K-9 Mail for Android In-Reply-To: References: <159169980416.23893.11862037394922372313@gitbox.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [jmeter] branch master updated: Better parse curl commands with backslash at line endings and support PUT method with data arguments To: dev@jmeter.apache.org From: Felix Schumacher Message-ID: Am 1=2E August 2020 22:58:35 MESZ schrieb Philippe Mouawad : >Hello Felix, >Sorry for noticing this a bit late=2E >See my remark inline below=2E > >Maybe I misunderstand the fix=2E > >Thanks >Regards > >On Tue, Jun 9, 2020 at 12:50 PM wrote: > >> This is an automated email from the ASF dual-hosted git repository=2E >> >> fschumacher pushed a commit to branch master >> in repository https://gitbox=2Eapache=2Eorg/repos/asf/jmeter=2Egit >> >> >> The following commit(s) were added to refs/heads/master by this push: >> new 353ad79 Better parse curl commands with backslash at line >> endings and support PUT method with data arguments >> 353ad79 is described below >> >> commit 353ad79c5497c4d624f8b276580b6b50d45b27b9 >> Author: Felix Schumacher >> AuthorDate: Tue Jun 9 12:49:00 2020 +0200 >> >> Better parse curl commands with backslash at line endings and >support >> PUT method with data arguments >> >> Bugzilla Id: 64446 >> --- >> =2E=2E=2E/jmeter/protocol/http/curl/BasicCurlParser=2Ejava | 6 +++= +-- >> =2E=2E=2E/org/apache/jmeter/curl/BasicCurlParserTest=2Ejava | 19 >> +++++++++++++++++++ >> xdocs/changes=2Exml | 1 + >> 3 files changed, 24 insertions(+), 2 deletions(-) >> >> diff --git >> >a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/curl/Ba= sicCurlParser=2Ejava >> >b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/curl/Ba= sicCurlParser=2Ejava >> index 0c7fcd6=2E=2E8d95da2 100644 >> --- >> >a/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/curl/Ba= sicCurlParser=2Ejava >> +++ >> >b/src/protocol/http/src/main/java/org/apache/jmeter/protocol/http/curl/Ba= sicCurlParser=2Ejava >> @@ -700,7 +700,9 @@ public class BasicCurlParser { >> String value =3D option=2EgetArgument(0); >> String dataOptionName =3D >> option=2EgetDescriptor()=2EgetName(); >> value =3D >getPostDataByDifferentOption(value=2Etrim(), >> dataOptionName); >> - request=2EsetMethod("POST"); >> + if ("GET"=2Eequals(request=2EgetMethod())) { >> + request=2EsetMethod("POST"); >> + } >> >Isn't it weird to transform a GET into a POST ? >Get with body data is possible in JMeter GET is the hard-coded default method=2E If the user doesn't set a method G= ET is returned=2E That means, we can't decide whether it is the default or = explicitly chosen=2E On the other hand side, before we set the method to PO= ST even if user chose a method explicitly=2E=20 So I think we are doing now a bit better in giving the user what was wante= d=2E=20 To make the GET case work in all circumstance we would have to change the = return value and that would cascade into quite a lot of places=2E=20 Regards=20 Felix=20 > > request=2EsetPostData(value); >> } else if >> (FORMS_OPT=2Econtains(option=2EgetDescriptor()=2EgetId())) { >> String nameAndValue =3D option=2EgetArgument(0); >> @@ -850,7 +852,7 @@ public class BasicCurlParser { >> current=2EsetLength(0); >> } >> } else { >> - current=2Eappend(nextTok); >> + =20 >current=2Eappend(nextTok=2EreplaceAll("^\\\\[\\r\\n]", >> "")); >> } >> lastTokenHasBeenQuoted =3D false; >> break; >> diff --git >> >a/src/protocol/http/src/test/java/org/apache/jmeter/curl/BasicCurlParserT= est=2Ejava >> >b/src/protocol/http/src/test/java/org/apache/jmeter/curl/BasicCurlParserT= est=2Ejava >> index 39f003b=2E=2Ec9f9228 100644 >> --- >> >a/src/protocol/http/src/test/java/org/apache/jmeter/curl/BasicCurlParserT= est=2Ejava >> +++ >> >b/src/protocol/http/src/test/java/org/apache/jmeter/curl/BasicCurlParserT= est=2Ejava >> @@ -89,6 +89,25 @@ public class BasicCurlParserTest { >> } >> >> @Test >> + public void testBackslashAtLineEnding() { >> + String cmdLine =3D "curl \\\n-d 'hey' >http://jmeter=2Eapache=2Eorg/"; >> + BasicCurlParser basicCurlParser =3D new BasicCurlParser(); >> + BasicCurlParser=2ERequest request =3D >basicCurlParser=2Eparse(cmdLine); >> + assertEquals("http://jmeter=2Eapache=2Eorg/", request=2EgetUrl= ()); >> + assertEquals("hey", request=2EgetPostData()); >> + } >> + >> + @Test >> + public void testSetRequestMethodOnData() { >> + String cmdLine =3D "curl -X PUT -d 'hey' >http://jmeter=2Eapache=2Eorg/ >> "; >> + BasicCurlParser basicCurlParser =3D new BasicCurlParser(); >> + BasicCurlParser=2ERequest request =3D >basicCurlParser=2Eparse(cmdLine); >> + assertEquals("http://jmeter=2Eapache=2Eorg/", request=2EgetUrl= ()); >> + assertEquals("hey", request=2EgetPostData()); >> + assertEquals("PUT", request=2EgetMethod()); >> + } >> + >> + @Test >> public void testChromeParsingNotCompressed() { >> String cmdLine =3D "curl 'https://jmeter=2Eapache=2Eorg/' -H >> 'Proxy-Connection: keep-alive' " >> + "-H 'Proxy-Authorization: Basic XXXXXXXXX/' -H >> 'Upgrade-Insecure-Requests: 1' " >> diff --git a/xdocs/changes=2Exml b/xdocs/changes=2Exml >> index f2c8db3=2E=2E0772b9a 100644 >> --- a/xdocs/changes=2Exml >> +++ b/xdocs/changes=2Exml >> @@ -109,6 +109,7 @@ Summary >> >>

General

>>
    >> +
  • 64446Better parse curl commands with backslash at >line >> endings and support PUT method with data arguments
  • >>
>> >> Non-functional changes >> >>