Return-Path: X-Original-To: apmail-hc-dev-archive@www.apache.org Delivered-To: apmail-hc-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A5B0D17897 for ; Fri, 12 Jun 2015 00:48:00 +0000 (UTC) Received: (qmail 230 invoked by uid 500); 12 Jun 2015 00:48:00 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 191 invoked by uid 500); 12 Jun 2015 00:48:00 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 178 invoked by uid 99); 12 Jun 2015 00:48:00 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Jun 2015 00:48:00 +0000 Date: Fri, 12 Jun 2015 00:48:00 +0000 (UTC) From: "Kevin Fongson (JIRA)" To: dev@hc.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (HTTPCLIENT-1658) Possible incorrect interaction in RequestBuilder.copy(...) and setURI(...) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Kevin Fongson created HTTPCLIENT-1658: ----------------------------------------- Summary: Possible incorrect interaction in RequestBuilder.copy(...) and setURI(...) Key: HTTPCLIENT-1658 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1658 Project: HttpComponents HttpClient Issue Type: Bug Components: HttpClient Affects Versions: 4.5, 4.4.1, 4.4 Final Reporter: Kevin Fongson Priority: Minor I recently upgraded my httpclient from 4.3.5 to 4.5 and noticed a difference in behavior in RequestBuilder. {code:title=Example.java|borderStyle=solid} @Test public void testUrlParams() { URI uri1 = URI.create("http://host1.com/path?param=something"); URI uri2 = URI.create("http://host2.com/path?param=somethingdifferent"); HttpRequest getRequest = new HttpGet(uri1); HttpUriRequest uriRequest = RequestBuilder.copy(getRequest).setUri(uri2).build(); Assert.assertEquals(uriRequest.getURI(), uri2); } // Output: // java.lang.AssertionError: expected [http://host2.com/path?param=somethingdifferent] but found [http://host2.com/path?param=somethingdifferent¶m=something] {code} I had expected the setUri(...) to completely overwrite the URI of the copied request, but the URL parameters from the copied request were also appended to the resulting request URI. This is different than how it behaves in 4.3.5. Looking at version 4.5 of RequestBuilder, the reason why this happens is that the parameters are extracted from the URI in line 305. They are then set on line 488 when the resulting request is built, regardless of whether the set URI already has parameters. Is this working as intended? -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org