hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r943614 - in /httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn: DefaultClientConnection.java LoggingSessionInputBuffer.java LoggingSessionOutputBuffer.java Wire.java
Date Wed, 12 May 2010 18:20:11 GMT
Author: olegk
Date: Wed May 12 18:20:11 2010
New Revision: 943614

URL: http://svn.apache.org/viewvc?rev=943614&view=rev
Log:
HTTPCLIENT-940: deprecated methods dependent on the default charset

Modified:
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/LoggingSessionInputBuffer.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/LoggingSessionOutputBuffer.java
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java?rev=943614&r1=943613&r2=943614&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java
Wed May 12 18:20:11 2010
@@ -43,6 +43,7 @@ import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpResponseFactory;
 import org.apache.http.params.HttpParams;
+import org.apache.http.params.HttpProtocolParams;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.impl.SocketHttpClientConnection;
 import org.apache.http.io.HttpMessageParser;
@@ -174,7 +175,10 @@ public class DefaultClientConnection ext
                 buffersize,
                 params);
         if (wireLog.isDebugEnabled()) {
-            inbuffer = new LoggingSessionInputBuffer(inbuffer, new Wire(wireLog));
+            inbuffer = new LoggingSessionInputBuffer(
+                    inbuffer,
+                    new Wire(wireLog),
+                    HttpProtocolParams.getHttpElementCharset(params));
         }
         return inbuffer;
     }
@@ -192,7 +196,10 @@ public class DefaultClientConnection ext
                 buffersize,
                 params);
         if (wireLog.isDebugEnabled()) {
-            outbuffer = new LoggingSessionOutputBuffer(outbuffer, new Wire(wireLog));
+            outbuffer = new LoggingSessionOutputBuffer(
+                    outbuffer,
+                    new Wire(wireLog),
+                    HttpProtocolParams.getHttpElementCharset(params));
         }
         return outbuffer;
     }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/LoggingSessionInputBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/LoggingSessionInputBuffer.java?rev=943614&r1=943613&r2=943614&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/LoggingSessionInputBuffer.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/LoggingSessionInputBuffer.java
Wed May 12 18:20:11 2010
@@ -32,6 +32,7 @@ import org.apache.http.annotation.Immuta
 
 import org.apache.http.io.HttpTransportMetrics;
 import org.apache.http.io.SessionInputBuffer;
+import org.apache.http.protocol.HTTP;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -49,15 +50,24 @@ public class LoggingSessionInputBuffer i
     /** The wire log to use for writing. */
     private final Wire wire;
 
+    private String charset;
+
     /**
      * Create an instance that wraps the specified session input buffer.
      * @param in The session input buffer.
      * @param wire The wire log to use.
+     * @param charset protocol charset, <code>ASCII</code> if <code>null</code>
      */
-    public LoggingSessionInputBuffer(final SessionInputBuffer in, final Wire wire) {
+    public LoggingSessionInputBuffer(
+            final SessionInputBuffer in, final Wire wire, final String charset) {
         super();
         this.in = in;
         this.wire = wire;
+        this.charset = charset != null ? charset : HTTP.ASCII;
+    }
+
+    public LoggingSessionInputBuffer(final SessionInputBuffer in, final Wire wire) {
+        this(in, wire, null);
     }
 
     public boolean isDataAvailable(int timeout) throws IOException {
@@ -91,7 +101,8 @@ public class LoggingSessionInputBuffer i
     public String readLine() throws IOException {
         String s = this.in.readLine();
         if (this.wire.enabled() && s != null) {
-            this.wire.input(s + "[EOL]");
+            String tmp = s + "\r\n";
+            this.wire.input(tmp.getBytes(this.charset));
         }
         return s;
     }
@@ -101,7 +112,8 @@ public class LoggingSessionInputBuffer i
         if (this.wire.enabled() && l >= 0) {
             int pos = buffer.length() - l;
             String s = new String(buffer.buffer(), pos, l);
-            this.wire.input(s + "[EOL]");
+            String tmp = s + "\r\n";
+            this.wire.input(tmp.getBytes(this.charset));
         }
         return l;
     }

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/LoggingSessionOutputBuffer.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/LoggingSessionOutputBuffer.java?rev=943614&r1=943613&r2=943614&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/LoggingSessionOutputBuffer.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/LoggingSessionOutputBuffer.java
Wed May 12 18:20:11 2010
@@ -32,6 +32,7 @@ import org.apache.http.annotation.Immuta
 
 import org.apache.http.io.HttpTransportMetrics;
 import org.apache.http.io.SessionOutputBuffer;
+import org.apache.http.protocol.HTTP;
 import org.apache.http.util.CharArrayBuffer;
 
 /**
@@ -49,15 +50,24 @@ public class LoggingSessionOutputBuffer 
     /** The wire log to use. */
     private final Wire wire;
 
+    private String charset;
+
     /**
      * Create an instance that wraps the specified session output buffer.
      * @param out The session output buffer.
      * @param wire The Wire log to use.
+     * @param charset protocol charset, <code>ASCII</code> if <code>null</code>
      */
-    public LoggingSessionOutputBuffer(final SessionOutputBuffer out, final Wire wire) {
+    public LoggingSessionOutputBuffer(
+            final SessionOutputBuffer out, final Wire wire, final String charset) {
         super();
         this.out = out;
         this.wire = wire;
+        this.charset = charset != null ? charset : HTTP.ASCII;
+    }
+
+    public LoggingSessionOutputBuffer(final SessionOutputBuffer out, final Wire wire) {
+        this(out, wire, null);
     }
 
     public void write(byte[] b, int off, int len) throws IOException {
@@ -89,14 +99,16 @@ public class LoggingSessionOutputBuffer 
         this.out.writeLine(buffer);
         if (this.wire.enabled()) {
             String s = new String(buffer.buffer(), 0, buffer.length());
-            this.wire.output(s + "[EOL]");
+            String tmp = s + "\r\n";
+            this.wire.output(tmp.getBytes(this.charset));
         }
     }
 
     public void writeLine(final String s) throws IOException {
         this.out.writeLine(s);
         if (this.wire.enabled()) {
-            this.wire.output(s + "[EOL]");
+            String tmp = s + "\r\n";
+            this.wire.output(tmp.getBytes(this.charset));
         }
     }
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java?rev=943614&r1=943613&r2=943614&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/conn/Wire.java
Wed May 12 18:20:11 2010
@@ -1,5 +1,4 @@
 /*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/java/org/apache/commons/httpclient/Wire.java,v
1.9 2004/06/24 21:39:52 mbecke Exp $
  * ====================================================================
  *
  *  Licensed to the Apache Software Foundation (ASF) under one or more
@@ -142,6 +141,7 @@ public class Wire {
         input(new byte[] {(byte) b});
     }
 
+    @Deprecated
     public void output(final String s)
       throws IOException {
         if (s == null) {
@@ -150,6 +150,7 @@ public class Wire {
         output(s.getBytes());
     }
 
+    @Deprecated
     public void input(final String s)
       throws IOException {
         if (s == null) {



Mime
View raw message