[PATCH] Removed encoding handling from http client
Wald Commits
scm-commit at wald.intevation.org
Thu Oct 31 19:04:03 CET 2013
# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1383242413 -3600
# Node ID 4ffbc9f79905ca4fd608f89481424167c35c4630
# Parent bacb661e6d3dbd7035041d41a55599945b4711eb
Removed encoding handling from http client.
diff -r bacb661e6d3d -r 4ffbc9f79905 src/main/java/org/dive4elements/artifacts/httpclient/http/HttpClient.java
--- a/src/main/java/org/dive4elements/artifacts/httpclient/http/HttpClient.java Thu Sep 26 19:55:53 2013 +0200
+++ b/src/main/java/org/dive4elements/artifacts/httpclient/http/HttpClient.java Thu Oct 31 19:00:13 2013 +0100
@@ -10,8 +10,6 @@
import java.io.InputStream;
import java.io.OutputStream;
-import java.nio.charset.Charset;
-
import org.w3c.dom.Document;
import org.dive4elements.artifacts.httpclient.exceptions.ConnectionException;
@@ -28,9 +26,6 @@
ArtifactFactory[] getArtifactFactories()
throws ConnectionException;
- public void setOutEncoding(Charset charset);
-
-
/*******************************
* Artifact API
*******************************/
diff -r bacb661e6d3d -r 4ffbc9f79905 src/main/java/org/dive4elements/artifacts/httpclient/http/HttpClientImpl.java
--- a/src/main/java/org/dive4elements/artifacts/httpclient/http/HttpClientImpl.java Thu Sep 26 19:55:53 2013 +0200
+++ b/src/main/java/org/dive4elements/artifacts/httpclient/http/HttpClientImpl.java Thu Oct 31 19:00:13 2013 +0100
@@ -7,15 +7,9 @@
*/
package org.dive4elements.artifacts.httpclient.http;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
import java.io.InputStream;
-import java.io.InputStreamReader;
import java.io.IOException;
import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-
-import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
@@ -46,7 +40,6 @@
import org.dive4elements.artifacts.httpclient.utils.ArtifactProtocolUtils;
import org.dive4elements.artifacts.httpclient.utils.ArtifactCreator;
-
/**
* Client to artifact-server.
* @author <a href="mailto:ingo.weinzierl at intevation.de">Ingo Weinzierl</a>
@@ -84,11 +77,6 @@
private String localeString;
- /**
- * The Charset used for encoding the collectionOut output.
- * If not set, the system/java default will be used (UTF-8).
- */
- private Charset charset;
private static final ThreadLocal<Client> CLIENT =
new ThreadLocal<Client>() {
@@ -101,22 +89,6 @@
public HttpClientImpl(String serverUrl) {
this.serverUrl = serverUrl;
- setOutEncoding(null);
- }
-
-
- /**
- * Sets the encoding.
- *
- * Currently the encoding is only
- * respected in the collectionOut-method!
- *
- * It was implemented to allow csv export to be in another than the
- * sensible default (UTF-8) and allow easier integration
- * e.g. in proprietary products.
- */
- public void setOutEncoding(Charset charset) {
- this.charset = charset;
}
@@ -294,6 +266,8 @@
request.setEntity(representation);
Response response = client.handle(request);
+ logger.debug("RESPONSE: " + response);
+
Status status = response.getStatus();
if (status.getCode() != 200) {
logger.error("Response status: " + status.getCode());
@@ -437,44 +411,6 @@
}
}
-
- /**
- * Write out() operation of a Collection to <i>out</i>, using buffered
- * reading and writing and a charset.
- *
- * @param in collection out to read from.
- * @param out The OutputStream to write transcoded answer to.
- */
- private void collectionOutEnc(
- InputStream in,
- OutputStream out)
- throws ConnectionException
- {
- try {
- BufferedReader reader =
- new BufferedReader(new InputStreamReader(in));
-
- BufferedWriter writer =
- new BufferedWriter(new OutputStreamWriter(out, this.charset));
-
- try {
- char[] c = new char[4096];
- int i;
- while ((i = reader.read(c)) >= 0) {
- writer.write(c, 0, i);
- }
- }
- finally {
- writer.flush();
- in.close();
- }
- }
- catch (IOException ioe) {
- throw new ConnectionException(ioe.getMessage(), ioe);
- }
- }
-
-
/**
* Write out() operation of a Collection to <i>out</i>.
*
@@ -493,12 +429,6 @@
try {
InputStream stream = collectionOut(doc, uuid, type);
- // Transcode if charset is given.
- if (charset != null) {
- collectionOutEnc(stream, out);
- return;
- }
-
try {
byte[] b = new byte[4096];
int i;
More information about the Dive4elements-commits
mailing list