commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r483949 - in /jakarta/commons/proper/httpclient/trunk: ./ src/java/org/apache/commons/httpclient/ src/java/org/apache/commons/httpclient/params/
Date Fri, 08 Dec 2006 11:34:51 GMT
Author: olegk
Date: Fri Dec  8 03:34:50 2006
New Revision: 483949

URL: http://svn.apache.org/viewvc?view=rev&rev=483949
Log:
Fix for [HTTPCLIENT-606] HttpMethodDirector fails when redirecting to a encoded URL location

changelog:

- Added a HTTP method level parameter for URI charset

Contributed by Oleg Kalnichevski <olegk at apache.org>

Modified:
    jakarta/commons/proper/httpclient/trunk/release_notes.txt
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/ConnectMethod.java
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodBase.java
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodDirector.java
    jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/params/HttpMethodParams.java

Modified: jakarta/commons/proper/httpclient/trunk/release_notes.txt
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/release_notes.txt?view=diff&rev=483949&r1=483948&r2=483949
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/release_notes.txt (original)
+++ jakarta/commons/proper/httpclient/trunk/release_notes.txt Fri Dec  8 03:34:50 2006
@@ -1,5 +1,8 @@
 Changes since Release 3.1 Beta 1:
 
+* [HTTPCLIENT-606] - Added a HTTP method level parameter for URI charset
+           Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 * [HTTPCLIENT-610] - Added for convenience HttpMethodBase.getResponseBodyAsString(int)
            Contributed by Ortwin Glueck <oglueck at apache.org>
            

Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/ConnectMethod.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/ConnectMethod.java?view=diff&rev=483949&r1=483948&r2=483949
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/ConnectMethod.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/ConnectMethod.java
Fri Dec  8 03:34:50 2006
@@ -116,7 +116,8 @@
     }
 
     public URI getURI() throws URIException {
-        return new URI(getPath(), true);
+        String charset = getParams().getUriCharset();
+        return new URI(getPath(), true, charset);
     }
 
     /**

Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodBase.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodBase.java?view=diff&rev=483949&r1=483948&r2=483949
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodBase.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodBase.java
Fri Dec  8 03:34:50 2006
@@ -218,7 +218,8 @@
             if (uri == null || uri.equals("")) {
                 uri = "/";
             }
-            setURI(new URI(uri, true));
+            String charset = getParams().getUriCharset();
+            setURI(new URI(uri, true, charset));
         } catch (URIException e) {
             throw new IllegalArgumentException("Invalid uri '" 
                 + uri + "': " + e.getMessage() 
@@ -262,7 +263,8 @@
             buffer.append('?');
             buffer.append(this.queryString);
         }
-        return new URI(buffer.toString(), true);
+        String charset = getParams().getUriCharset();
+        return new URI(buffer.toString(), true, charset);
     }
 
     /**

Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodDirector.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodDirector.java?view=diff&rev=483949&r1=483948&r2=483949
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodDirector.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/HttpMethodDirector.java
Fri Dec  8 03:34:50 2006
@@ -596,8 +596,11 @@
                 this.conn.getPort(), 
 				method.getPath()
 			);
-			redirectUri = new URI(location, true);
-			if (redirectUri.isRelativeURI()) {
+			
+            String charset = method.getParams().getUriCharset();
+            redirectUri = new URI(location, true, charset);
+			
+            if (redirectUri.isRelativeURI()) {
 				if (this.params.isParameterTrue(HttpClientParams.REJECT_RELATIVE_REDIRECT)) {
 					LOG.warn("Relative redirect location '" + location + "' not allowed");
 					return false;

Modified: jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/params/HttpMethodParams.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/params/HttpMethodParams.java?view=diff&rev=483949&r1=483948&r2=483949
==============================================================================
--- jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/params/HttpMethodParams.java
(original)
+++ jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/params/HttpMethodParams.java
Fri Dec  8 03:34:50 2006
@@ -167,6 +167,14 @@
     public static final String HTTP_ELEMENT_CHARSET = "http.protocol.element-charset"; 
     
     /**
+     * Defines the charset to be used for parsing URIs.
+     * <p>
+     * This parameter expects a value of type {@link String}.
+     * </p>
+     */
+    public static final String HTTP_URI_CHARSET = "http.protocol.uri-charset"; 
+    
+    /**
      * Defines the charset to be used for encoding content body.
      * <p>
      * This parameter expects a value of type {@link String}.
@@ -332,6 +340,26 @@
         if (charset == null) {
             LOG.warn("Default content charset not configured, using ISO-8859-1");
             charset = "ISO-8859-1";
+        }
+        return charset;
+    }
+    
+    /**
+     * Sets the charset to be used for parsing URIs.
+     * @param charset The charset
+     */
+    public void setUriCharset(String charset) {
+        setParameter(HTTP_URI_CHARSET, charset);
+    }
+
+    /**
+     * Returns the charset to be used for parsing URIs.
+     * @return The charset
+     */
+    public String getUriCharset() {
+        String charset = (String) getParameter(HTTP_URI_CHARSET);
+        if (charset == null) {
+            charset = "UTF-8";
         }
         return charset;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message