Hello Ingo, Rob,

I think your patch does work for most cases (as utf-8 is mostly the default
used encoding), but if the XML document is using a different encoding,
things may break.
I can see another problem: If the application decided to set the
content-type header to the used encoding, the current implementation would
overwrite the application's setting, isn't it.

Rob, if I understand your mail correctly, the encoding problem arises only,
if the body is set as a string (as the httpClient needs to convert the
string into bytes). Couldn't we make the patch to work only in this specific
case (string needs to be converted to byte and the content header was not
set before).

Best regards

Juergen




-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Donnerstag, 27. Februar 2003 11:58
To: [EMAIL PROTECTED]
Subject: cvs commit:
jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods
SearchMethod.java ReportMethod.java PropPatchMethod.java PropFindMethod.java
OptionsMethod.java LockMethod.java LabelMethod.java
HttpRequestBodyMethodBase.java AclMethod.java

ib          2003/02/27 02:58:26

  Modified:    src/webdav/client/src/org/apache/webdav/lib/methods
                        SearchMethod.java ReportMethod.java
                        PropPatchMethod.java PropFindMethod.java
                        OptionsMethod.java LockMethod.java LabelMethod.java
                        HttpRequestBodyMethodBase.java AclMethod.java
  Log:
  Fix charset encoding for certain WebDAV methods by setting the
  Content-Type header before setting the request body
  
  Submitted by: Rob Owen ([EMAIL PROTECTED])
  
  Revision  Changes    Path
  1.8       +4 -4
jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/SearchMeth
od.java
  
  Index: SearchMethod.java
  ===================================================================
  RCS file:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/
SearchMethod.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SearchMethod.java 16 Dec 2002 15:17:28 -0000      1.7
  +++ SearchMethod.java 27 Feb 2003 10:58:25 -0000      1.8
  @@ -216,8 +216,8 @@
       public void addRequestHeaders(HttpState state, HttpConnection conn)
       throws IOException, HttpException {
   
  -        super.addRequestHeaders(state, conn);
           super.setRequestHeader("Content-Type", "text/xml;
charset=utf-8");
  +        super.addRequestHeaders(state, conn);
   
       }
   
  
  
  
  1.6       +5 -5
jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/ReportMeth
od.java
  
  Index: ReportMethod.java
  ===================================================================
  RCS file:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/
ReportMethod.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ReportMethod.java 16 Dec 2002 15:17:28 -0000      1.5
  +++ ReportMethod.java 27 Feb 2003 10:58:26 -0000      1.6
  @@ -366,9 +366,9 @@
       public void addRequestHeaders(HttpState state, HttpConnection conn)
       throws IOException, HttpException {
   
  -        super.addRequestHeaders(state, conn);
  -
           super.setRequestHeader("Content-Type", "text/xml;
charset=utf-8");
  +
  +        super.addRequestHeaders(state, conn);
   
           switch (depth) {
           case DEPTH_0:
  
  
  
  1.24      +5 -5
jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/PropPatchM
ethod.java
  
  Index: PropPatchMethod.java
  ===================================================================
  RCS file:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/
PropPatchMethod.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- PropPatchMethod.java      16 Dec 2002 15:17:28 -0000      1.23
  +++ PropPatchMethod.java      27 Feb 2003 10:58:26 -0000      1.24
  @@ -225,9 +225,9 @@
       public void addRequestHeaders(HttpState state, HttpConnection conn)
       throws IOException, HttpException {
   
  -        super.addRequestHeaders(state, conn);
  -
           super.setRequestHeader("Content-Type", "text/xml;
charset=utf-8");
  +
  +        super.addRequestHeaders(state, conn);
   
       }
   
  
  
  
  1.33      +5 -5
jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/PropFindMe
thod.java
  
  Index: PropFindMethod.java
  ===================================================================
  RCS file:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/
PropFindMethod.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- PropFindMethod.java       16 Dec 2002 15:17:28 -0000      1.32
  +++ PropFindMethod.java       27 Feb 2003 10:58:26 -0000      1.33
  @@ -375,9 +375,9 @@
       public void addRequestHeaders(HttpState state, HttpConnection conn)
       throws IOException, HttpException {
   
  -        super.addRequestHeaders(state, conn);
  -
           super.setRequestHeader("Content-Type", "text/xml;
charset=utf-8");
  +
  +        super.addRequestHeaders(state, conn);
   
           switch (depth) {
           case DEPTH_0:
  
  
  
  1.15      +5 -5
jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/OptionsMet
hod.java
  
  Index: OptionsMethod.java
  ===================================================================
  RCS file:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/
OptionsMethod.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- OptionsMethod.java        16 Dec 2002 15:17:28 -0000      1.14
  +++ OptionsMethod.java        27 Feb 2003 10:58:26 -0000      1.15
  @@ -343,13 +343,13 @@
           //get and set header
        public void addRequestHeaders(HttpState state, HttpConnection conn)
        throws IOException, HttpException {
  -
  -         super.addRequestHeaders(state, conn);
            
            if (type!= 0){
               super.setRequestHeader("Content-Type", "text/xml;
charset=utf-8");
               //System.out.println("Content-Type set" );
            }
  +
  +         super.addRequestHeaders(state, conn);
        }
   
   /**
  
  
  
  1.34      +4 -5
jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/LockMethod
.java
  
  Index: LockMethod.java
  ===================================================================
  RCS file:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/
LockMethod.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- LockMethod.java   16 Dec 2002 15:17:28 -0000      1.33
  +++ LockMethod.java   27 Feb 2003 10:58:26 -0000      1.34
  @@ -439,6 +439,7 @@
       public void addRequestHeaders(HttpState state, HttpConnection conn)
       throws IOException, HttpException {
   
  +        super.setRequestHeader("Content-Type", "text/xml;
charset=utf-8");
           super.addRequestHeaders(state, conn);
   
           switch (depth) {
  @@ -460,8 +461,6 @@
           if (isRefresh()) {
               super.setRequestHeader("If", "(<" + refreshOpaqueToken +
">)");
           }
  -
  -        super.setRequestHeader("Content-Type", "text/xml;
charset=utf-8");
   
       }
   
  
  
  
  1.9       +4 -4
jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/LabelMetho
d.java
  
  Index: LabelMethod.java
  ===================================================================
  RCS file:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/
LabelMethod.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- LabelMethod.java  16 Dec 2002 15:17:28 -0000      1.8
  +++ LabelMethod.java  27 Feb 2003 10:58:26 -0000      1.9
  @@ -204,8 +204,8 @@
        */
       public void addRequestHeaders(HttpState state, HttpConnection conn)
       throws IOException, HttpException {
  -        super.addRequestHeaders(state, conn);
           super.setRequestHeader("Content-Type", "text/xml;
charset=utf-8");
  +        super.addRequestHeaders(state, conn);
       }
   
       /**
  
  
  
  1.4       +5 -4
jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/HttpReques
tBodyMethodBase.java
  
  Index: HttpRequestBodyMethodBase.java
  ===================================================================
  RCS file:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/
HttpRequestBodyMethodBase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- HttpRequestBodyMethodBase.java    16 Dec 2002 16:46:00 -0000      1.3
  +++ HttpRequestBodyMethodBase.java    27 Feb 2003 10:58:26 -0000      1.4
  @@ -75,6 +75,7 @@
   import org.apache.commons.httpclient.HttpMethodBase;
   import org.apache.commons.httpclient.HttpState;
   import org.apache.commons.httpclient.HttpStatus;
  +import org.apache.commons.httpclient.HttpConstants;
   
   
   /**
  @@ -171,7 +172,7 @@
        */
       public void setRequestBody(String bodydata) {
           checkNotUsed();
  -        setRequestBody(bodydata.getBytes());
  +        setRequestBody(HttpConstants.getContentBytes(bodydata,
getRequestCharSet()));
       }
   
       /**
  
  
  
  1.9       +4 -4
jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/AclMethod.
java
  
  Index: AclMethod.java
  ===================================================================
  RCS file:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/methods/
AclMethod.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AclMethod.java    16 Dec 2002 15:17:28 -0000      1.8
  +++ AclMethod.java    27 Feb 2003 10:58:26 -0000      1.9
  @@ -148,8 +148,8 @@
       public void addRequestHeaders(HttpState state, HttpConnection conn)
       throws IOException, HttpException {
   
  -        super.addRequestHeaders(state, conn);
           super.setRequestHeader("Content-Type", "text/xml;
charset=utf-8");
  +        super.addRequestHeaders(state, conn);
   
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to