Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 6CCEC200C34 for ; Mon, 27 Feb 2017 12:26:17 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 6B5AF160B6C; Mon, 27 Feb 2017 11:26:17 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 69D86160B60 for ; Mon, 27 Feb 2017 12:26:16 +0100 (CET) Received: (qmail 95817 invoked by uid 500); 27 Feb 2017 11:26:15 -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 95805 invoked by uid 99); 27 Feb 2017 11:26:15 -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; Mon, 27 Feb 2017 11:26:15 +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 927001A03FC for ; Mon, 27 Feb 2017 11:26:14 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.68 X-Spam-Level: * X-Spam-Status: No, score=1.68 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, HTML_OBFUSCATE_05_10=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_SORBS_SPAM=0.5, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id PBguk0x2viY8 for ; Mon, 27 Feb 2017 11:26:11 +0000 (UTC) Received: from mail-qk0-f170.google.com (mail-qk0-f170.google.com [209.85.220.170]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 207AA5F23A for ; Mon, 27 Feb 2017 11:26:11 +0000 (UTC) Received: by mail-qk0-f170.google.com with SMTP id s186so91853497qkb.1 for ; Mon, 27 Feb 2017 03:26:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=N3OzIV5iUWZgsglsF1ZW8ejRwSE5jdkopy9C5zC7ihQ=; b=q9P016vd0aFFe7eKapQTHZ8C/r01sKU94hs5k8JF1kEZ9C/ACK27aeTEFDUSql5BCg 7/xnj7VoqoLw651xSichVP9N/832sYXFm0oRY1MIMfM+SAjkX2N5R/S6f92QgrVSH8qe CIL5/LLGYtfdlOomzeDCekMPPqXRI1tmoNMlCDGJdBny+bwz1iDu8cvQV5WSnRRWf6v8 OfgazzMMdXzDMLlh63rZebmlt7nhvXLAIvXIdXLVJjo7dbAddIfvz2pTxECjCPh6WfKF Y61bsr8uiOVc3fpV1a42J3ztq/1bw8TsHEyZV0KGM6m8K5et8KRm7t/TvnIApNpZl/8u toQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=N3OzIV5iUWZgsglsF1ZW8ejRwSE5jdkopy9C5zC7ihQ=; b=atWrBNkPenB2UD0Uirxwuf2FFftYvpksa7a5oLAV5RkTuIPT9MeidGlaztjIyyHyBN EZJ4QtI+45uTnrE0jbJYh/280cUR9Uf+7PIwja8oKneYEehuKPVRg1cq/YDsIx+KtRGE M2i7SEJ0s+XwtgSfEaKeXhBH9gIE4JjLGL39bVfsusjwYDrgY6Y9sM/DDTtYYd+82nQy jz0A4aCTuR/2qftgdD/bxchnXuYSKyayesjhjdhQnpVhLSdSvXcUr9uX96BqatgTdEFQ FBv5kJfH6aMiXsziZXXD4z18FF+OCz056LdX+02qS/i1N61dR0B2RlLk6068xfhA3RoH hhLQ== X-Gm-Message-State: AMke39lxel5XSJHGkMnB9j73nY9WH4QIHVOYVtvkNgKHKtPx6K6xsZlihqO9UC2scelAsv8mnwZzIgHsP53BEA== X-Received: by 10.200.53.99 with SMTP id z32mr16420340qtb.106.1488194770434; Mon, 27 Feb 2017 03:26:10 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.147.173 with HTTP; Mon, 27 Feb 2017 03:26:09 -0800 (PST) In-Reply-To: References: <20170227075744.350353A059D@svn01-us-west.apache.org> From: Philippe Mouawad Date: Mon, 27 Feb 2017 12:26:09 +0100 Message-ID: Subject: Re: svn commit: r1784506 - in /jmeter/trunk: build.xml src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java xdocs/changes.xml To: "dev@jmeter.apache.org" Content-Type: multipart/alternative; boundary=001a113ba366a602eb0549815824 archived-at: Mon, 27 Feb 2017 11:26:17 -0000 --001a113ba366a602eb0549815824 Content-Type: text/plain; charset=UTF-8 On Mon, Feb 27, 2017 at 11:17 AM, sebb wrote: > On 27 February 2017 at 07:57, wrote: > > Author: pmouawad > > Date: Mon Feb 27 07:57:43 2017 > > New Revision: 1784506 > > > > URL: http://svn.apache.org/viewvc?rev=1784506&view=rev > > Log: > > Bug 60778 - Http Java Impl does not show Authorization header in > SampleResult even if it is sent > > Bugzilla Id: 60778 > > > > Modified: > > jmeter/trunk/build.xml > > jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/ > http/sampler/HTTPJavaImpl.java > > jmeter/trunk/xdocs/changes.xml > > > > Modified: jmeter/trunk/build.xml > > URL: http://svn.apache.org/viewvc/jmeter/trunk/build.xml?rev=1784 > 506&r1=1784505&r2=1784506&view=diff > > ============================================================ > ================== > > --- jmeter/trunk/build.xml (original) > > +++ jmeter/trunk/build.xml Mon Feb 27 07:57:43 2017 > > @@ -2739,6 +2739,13 @@ run JMeter unless all the JMeter jars ar > > > > > > > > + > > + > > + > > + > > + > > + > > + > > > > > > > > > > Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/ > http/sampler/HTTPJavaImpl.java > > URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/ > org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl. > java?rev=1784506&r1=1784505&r2=1784506&view=diff > > ============================================================ > ================== > > --- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java > (original) > > +++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPJavaImpl.java > Mon Feb 27 07:57:43 2017 > > @@ -26,6 +26,7 @@ import java.net.InetSocketAddress; > > import java.net.Proxy; > > import java.net.URL; > > import java.net.URLConnection; > > +import java.util.HashMap; > > import java.util.List; > > import java.util.Map; > > import java.util.zip.GZIPInputStream; > > @@ -63,7 +64,6 @@ public class HTTPJavaImpl extends HTTPAb > > > > static { > > log.info("Maximum connection retries = {}", MAX_CONN_RETRIES); > // $NON-NLS-1$ > > - // Temporary copies, so can set the final ones > > } > > > > private static final byte[] NULL_BA = new byte[0];// can share these > > @@ -183,6 +183,9 @@ public class HTTPJavaImpl extends HTTPAb > > // with the last request to an HTTP server. Instead, most > browsers > > // leave it to the server to close the connection after their > > // timeout period. Leave it to the JMeter user to decide. > > + // Ensure System property "" is set to true to allow headers > > Missing property name > Good catch , fixed > > > + // such as "Host" and "Connection" to be passed through. > > + // See http://bugs.java.com/bugdataba > se/view_bug.do?bug_id=6996110 > > if (getUseKeepAlive()) { > > conn.setRequestProperty(HTTPConstants.HEADER_CONNECTION, > HTTPConstants.KEEP_ALIVE); > > } else { > > @@ -193,7 +196,7 @@ public class HTTPJavaImpl extends HTTPAb > > setConnectionHeaders(conn, u, getHeaderManager(), > getCacheManager()); > > String cookies = setConnectionCookie(conn, u, > getCookieManager()); > > > > - setConnectionAuthorization(conn, u, getAuthManager()); > > + Map securityHeaders = > setConnectionAuthorization(conn, u, getAuthManager()); > > > > if (method.equals(HTTPConstants.POST)) { > > setPostHeaders(conn); > > @@ -202,7 +205,7 @@ public class HTTPJavaImpl extends HTTPAb > > } > > > > if (res != null) { > > - res.setRequestHeaders(getConnectionHeaders(conn)); > > + res.setRequestHeaders(getConnectionHeaders(conn, > securityHeaders)); > > res.setCookies(cookies); > > } > > > > @@ -383,9 +386,10 @@ public class HTTPJavaImpl extends HTTPAb > > * @param conn > > * HttpUrlConnection which represents the > URL > > * request > > + * @param securityHeaders Map of security Header or null > > * @return the headers as a string > > */ > > - private String getConnectionHeaders(HttpURLConnection conn) { > > + private String getConnectionHeaders(HttpURLConnection conn, > Map securityHeaders) { > > // Get all the request properties, which are the headers set on > the connection > > StringBuilder hdrs = new StringBuilder(100); > > Map> requestHeaders = > conn.getRequestProperties(); > > @@ -402,6 +406,14 @@ public class HTTPJavaImpl extends HTTPAb > > } > > } > > } > > + if(securityHeaders != null) { > > + for(Map.Entry entry : > securityHeaders.entrySet()) { > > + hdrs.append(entry.getKey()) > > + .append(": ") // $NON-NLS-1$ > > + .append(entry.getValue()) > > + .append("\n"); // $NON-NLS-1$ > > + } > > + } > > return hdrs.toString(); > > } > > > > @@ -417,14 +429,20 @@ public class HTTPJavaImpl extends HTTPAb > > * @param authManager > > * the AuthManager containing all the > cookies for > > * this UrlConfig > > + * @return String Authorization header value or null if not set > > */ > > - private void setConnectionAuthorization(HttpURLConnection conn, > URL u, AuthManager authManager) { > > + private Map setConnectionAuthorization(HttpURLConnection > conn, URL u, AuthManager authManager) { > > if (authManager != null) { > > Authorization auth = authManager.getAuthForURL(u); > > if (auth != null) { > > - conn.setRequestProperty(HTTPConstants.HEADER_AUTHORIZATION, > auth.toBasicHeader()); > > + String headerValue = auth.toBasicHeader(); > > + conn.setRequestProperty(HTTPConstants.HEADER_AUTHORIZATION, > headerValue); > > + Map map = new HashMap<>(1); > > + map.put(HTTPConstants.HEADER_AUTHORIZATION, > headerValue); > > + return map; > > } > > } > > + return null; > > It'a almost always better to return an empty array or collection > instead of null. > Simplifies the code as callers don't need to check for null. > I usually agree with such rule but not here as it will result in a lot of object creation for nothing. > > > } > > > > /** > > > > Modified: jmeter/trunk/xdocs/changes.xml > > URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml? > rev=1784506&r1=1784505&r2=1784506&view=diff > > ============================================================ > ================== > > --- jmeter/trunk/xdocs/changes.xml [utf-8] (original) > > +++ jmeter/trunk/xdocs/changes.xml [utf-8] Mon Feb 27 07:57:43 2017 > > @@ -243,6 +243,7 @@ JMeter now requires Java 8. Ensure you u > >
  • 60690Default values for > "httpclient4.validate_after_inactivity" and "httpclient4.time_to_live" > which are equal to each other makes validation useless
  • > >
  • 60758HTTP(s) Test Script Recorder : Number request > may generate duplicate numbers. Contributed by Ubik Load Pack (support at > ubikloadpack.com)
  • > >
  • 56939Parameters are not passed with OPTIONS HTTP > Request
  • > > +
  • 60778Http Java Impl does not show Authorization > header in SampleResult even if it is sent
  • > > > > > >

    Other Samplers

    > > > > > -- Cordialement. Philippe Mouawad. --001a113ba366a602eb0549815824--