commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jeri...@apache.org
Subject cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java
Date Sun, 20 Oct 2002 13:34:56 GMT
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;
   
   /**
    * <p>
  @@ -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:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message