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 547A518040 for ; Tue, 28 Jul 2015 16:23:21 +0000 (UTC) Received: (qmail 5501 invoked by uid 500); 28 Jul 2015 16:23:05 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 5458 invoked by uid 500); 28 Jul 2015 16:23:05 -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 5380 invoked by uid 99); 28 Jul 2015 16:23:05 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Jul 2015 16:23:05 +0000 Date: Tue, 28 Jul 2015 16:23:05 +0000 (UTC) From: "Steve Davids (JIRA)" To: dev@hc.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (HTTPCLIENT-1671) RequestDefaultHeaders should only be set if the header hasn't already been set MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Steve Davids created HTTPCLIENT-1671: ---------------------------------------- Summary: RequestDefaultHeaders should only be set if the header hasn't already been set Key: HTTPCLIENT-1671 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1671 Project: HttpComponents HttpClient Issue Type: Improvement Components: HttpClient Reporter: Steve Davids The name implies that default header values will be applied to the request which generally means that if the request doesn't specify a header value then the default is applied. For example: {code} defaultHeaderValue = ["Accept": "application/json"] httpClient.execute(new HttpGet(url)); //header should be application/json HttpGet get = new HttpGet(url); get.setHeader("Accept", "application/xml"); httpClient.execute(get); //header should be application/xml, *not* application/xml, application/json {code} A simple fix would be to add the following code snippet: {code} if(!request.containsHeader(defHeader.getName)) { request.addHeader(defHeader); } {code} -- 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