juergen 2002/09/24 05:41:50
Modified: src/webdav/client/src/org/apache/commons/httpclient
HttpClient.java Header.java
Log:
The label header must be transmitted as a utf-8 encoded header.
Revision Changes Path
1.15 +11 -11
jakarta-slide/src/webdav/client/src/org/apache/commons/httpclient/HttpClient.java
Index: HttpClient.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/commons/httpclient/HttpClient.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- HttpClient.java 9 Sep 2002 10:49:01 -0000 1.14
+++ HttpClient.java 24 Sep 2002 12:41:50 -0000 1.15
@@ -436,7 +436,7 @@
}
}
}
-
+
retries = 0;
methodProcessed = false;
@@ -521,11 +521,11 @@
// Parse headers
responseHeaders = parseHeaders(input);
-
+
// if (method.getStatusCode() == 500) {
// while (input.available() > 0) System.out.println("### " +
readLine(input));
// }
-
+
}
@@ -826,7 +826,7 @@
param[0] = this.sessionHost;
param[1] = new Integer(this.sessionPort);
socket = (Socket)
createSocketMethod.invoke(sslSocketFactory,param);
-
+
} else {
socket = new Socket
(this.sessionHost, this.sessionPort);
@@ -934,7 +934,7 @@
String hostName = sessionHost;
if (sessionPort != 80)
hostName = hostName + ":" + sessionPort;
-
+
method.generateHeaders(this.https, hostName, state);
Enumeration headersList = method.getHeaders();
@@ -995,7 +995,7 @@
Header header = (Header) headersList.nextElement();
if (debug > 1)
System.out.print(header.toString());
- output.write(header.toString().getBytes());
+ output.write(header.getBytes());
}
if (debug > 1)
@@ -1155,11 +1155,11 @@
int colon = line.indexOf(":");
if (colon < 0)
throw new HttpException("Incorrect headers");
-
+
String name = line.substring(0, colon).trim();
String match = name.toLowerCase();
String value = line.substring(colon + 1).trim();
-
+
Header oldHeader = (Header)result.get(match);
if (oldHeader != null) {
value = oldHeader.getValue() + ", " + value;
1.4 +50 -28
jakarta-slide/src/webdav/client/src/org/apache/commons/httpclient/Header.java
Index: Header.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/commons/httpclient/Header.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Header.java 25 Apr 2002 21:12:31 -0000 1.3
+++ Header.java 24 Sep 2002 12:41:50 -0000 1.4
@@ -7,7 +7,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -15,7 +15,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
@@ -23,15 +23,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Slide", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
+ * from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
@@ -59,7 +59,7 @@
*
* [Additional notices, if required by prior licensing conditions]
*
- */
+ */
package org.apache.commons.httpclient;
@@ -73,47 +73,69 @@
/**
* Header class.
- *
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">Remy Maucherat</a>
*/
public class Header extends NameValuePair {
-
-
+
+
// ----------------------------------------------------------- Constructors
-
-
+
+
/**
* Default constructor.
*/
public Header() {
}
-
-
+
+
/**
* Constructor.
*/
public Header(String name, String value) {
-
+
super(name, value);
-
+
}
-
-
+
+
// ----------------------------------------------------- Instance Variables
-
-
+
+
// ------------------------------------------------------------- Properties
-
-
+
+
// --------------------------------------------------------- Public Methods
-
-
+
+
/**
* Get a String representation of the header.
*/
public String toString() {
return (name + ": " + value + "\r\n");
}
-
-
+
+
+ /**
+ * Get a Byte representation of the header.
+ */
+ public byte[] getBytes() {
+ if (!name.equalsIgnoreCase("Label")) {
+ return toString().getBytes();
+ } else {
+ return getBytes("UTF-8");
+ }
+ }
+
+ /**
+ * Get a Byte representation of the header.
+ */
+ public byte[] getBytes(String encoding) {
+ try {
+ return toString().getBytes(encoding);
+ } catch (java.io.UnsupportedEncodingException e) {e.printStackTrace();}
+ return toString().getBytes();
+ }
+
+
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>