From commons-dev-return-12984-qmlist-jakarta-archive-commons-dev=jakarta.apache.org@jakarta.apache.org Fri Aug 02 11:40:52 2002 Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 10709 invoked from network); 2 Aug 2002 11:40:51 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 2 Aug 2002 11:40:51 -0000 Received: (qmail 23826 invoked by uid 97); 2 Aug 2002 11:41:09 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 23778 invoked by uid 97); 2 Aug 2002 11:41:08 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 23767 invoked by uid 97); 2 Aug 2002 11:41:08 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Date: 2 Aug 2002 11:40:45 -0000 Message-ID: <20020802114045.73718.qmail@icarus.apache.org> From: jsdever@apache.org To: jakarta-commons-cvs@apache.org Subject: cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N jsdever 2002/08/02 04:40:45 Modified: httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java Log: Fix for http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11220 Changes the logic for when to add the Host header with the default port or not. Based on patch by Xiaowei Jiang Revision Changes Path 1.42 +21 -15 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java Index: HttpMethodBase.java =================================================================== RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v retrieving revision 1.41 retrieving revision 1.42 diff -u -r1.41 -r1.42 --- HttpMethodBase.java 2 Aug 2002 06:37:26 -0000 1.41 +++ HttpMethodBase.java 2 Aug 2002 11:40:45 -0000 1.42 @@ -944,19 +944,25 @@ String host = conn.getHost(); int port = conn.getPort(); + + if (requestHeaders.containsKey("host")){ + log.debug("Request to add Host header ignored: header already added"); + return; + } - if (!requestHeaders.containsKey("host")) { - if (!isIpAddress(host)) { - if (port == 80) { - setRequestHeader("Host", host); - } else { - setRequestHeader("Host", host + ":" + port); - } - } else { - setRequestHeader("Host", ""); - } + if (isIpAddress(host)) { + log.debug("Request to add Host header ignored: host is an ipaddress"); + return; } - } + + log.debug("Adding Host request header"); + //appends the port only if not using the default port for the protocol + if(conn.isSecure()) { + setRequestHeader("Host", (port==443) ? host : host+':'+port); + } else { + setRequestHeader("Host", (port==80) ? host : host+':'+port); + } + } /** * Adds a Cookie request containing the matching {@link Cookie}s. -- To unsubscribe, e-mail: For additional commands, e-mail: