Mercurial > dive4elements > http-client
changeset 96:4ffbc9f79905 3.0.17
Removed encoding handling from http client.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 31 Oct 2013 19:00:13 +0100 |
parents | bacb661e6d3d |
children | 6a2d73b6f6ed |
files | src/main/java/org/dive4elements/artifacts/httpclient/http/HttpClient.java src/main/java/org/dive4elements/artifacts/httpclient/http/HttpClientImpl.java |
diffstat | 2 files changed, 2 insertions(+), 77 deletions(-) [+] |
line wrap: on
line diff
--- 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 *******************************/
--- 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@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;