Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 76694 invoked from network); 20 Oct 2002 13:35:12 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 20 Oct 2002 13:35:12 -0000 Received: (qmail 18425 invoked by uid 97); 20 Oct 2002 13:35:58 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 18374 invoked by uid 97); 20 Oct 2002 13:35:57 -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 18359 invoked by uid 97); 20 Oct 2002 13:35:56 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Date: 20 Oct 2002 13:34:56 -0000 Message-ID: <20021020133456.22937.qmail@icarus.apache.org> From: jericho@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 jericho 2002/10/20 06:34:56 Modified: httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java Log: - Use httpclient.util.URIUtil methods instead of httpclient.URIUtil - Fix a bug not to encode of the query component, when the generateRequestLine method do - minor local variable naming change (from an abbreviation to a full string) Revision Changes Path 1.66 +46 -19 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.65 retrieving revision 1.66 diff -u -r1.65 -r1.66 --- HttpMethodBase.java 16 Oct 2002 16:58:26 -0000 1.65 +++ HttpMethodBase.java 20 Oct 2002 13:34:55 -0000 1.66 @@ -77,6 +77,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.commons.httpclient.util.URIUtil; /** *

@@ -401,9 +402,23 @@ } else { needAmp = true; } - buf.append(URIUtil.encode(params[i].getName())).append("="); + String queryName = null; + try { + queryName = URIUtil.encodeQuery(params[i].getName()); + } catch (URIException urie) { + log.error("URI query name encoding error", urie); + queryName = params[i].getName(); + } + buf.append(queryName).append("="); if (params[i].getValue() != null) { - buf.append(URIUtil.encode(params[i].getValue())); + String queryValue = null; + try { + queryValue = URIUtil.encodeQuery(params[i].getValue()); + } catch (URIException urie) { + log.error("URI query value encoding error", urie); + queryValue = params[i].getValue(); + } + buf.append(queryValue); } } } @@ -855,11 +870,11 @@ return statusCode; } - //change the path and query string to the redirect + // change the path and query string to the redirect String absolutePath = URIUtil.getPath(url.toString()); - String qs = URIUtil.getQueryString(url.toString()); + String query = URIUtil.getQuery(url.toString()); setPath(URIUtil.decode(absolutePath)); - setQueryString(qs); + setQueryString(URIUtil.decode(query)); if (log.isDebugEnabled()) { log.debug("Changing path from \"" + getPath() @@ -867,7 +882,7 @@ + "\" in response to " + statusCode + " response."); log.debug("Changing query string from \"" - + getQueryString() + "\" to \"" + qs + + getQueryString() + "\" to \"" + query + "\" in response to " + statusCode + " response."); } @@ -1289,26 +1304,38 @@ * * @param connection the connection the request will be sent to * @param name the method name generate a request for - * @param reqPath the path for the request - * @param qString the query string for the request + * @param requestPath the path string for the request + * @param query the query string for the request * @param protocol the protocol to use (e.g. HTTP/1.0) * * @return a line to send to the server that will fulfil the request */ protected static String generateRequestLine(HttpConnection connection, - String name, String reqPath, - String qString, String protocol) { + String name, String requestPath, String query, String protocol) { log.trace("enter HttpMethodBase.generateRequestLine(HttpConnection, " + "String, String, String, String)"); StringBuffer buf = new StringBuffer(); - buf.append((null == reqPath) - ? "/" : URIUtil.encode(reqPath, URIUtil.pathSafe())); - if (null != qString) { - if (qString.indexOf("?") < 0) { + String path = null; + try { + path = (requestPath == null) ? "/" : URIUtil.encodePath(requestPath); + } catch (URIException urie) { + log.error("URI path encoding error"); + path = requestPath; + } + buf.append(path); + if (query != null) { + if (query.indexOf("?") < 0) { buf.append("?"); } - buf.append(qString); + String queryString = null; + try { + queryString = (query == null) ? "/" : URIUtil.encodeQuery(query); + } catch (URIException urie) { + log.error("URI query encoding error"); + queryString = query; + } + buf.append(queryString); } if (!connection.isProxied() || connection.isTransparent()) { -- To unsubscribe, e-mail: For additional commands, e-mail: