mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-17 02:14:54 +00:00
more support for wares
This commit is contained in:
parent
8d867dc24c
commit
d8bec39b73
@ -115,18 +115,15 @@ public abstract class Streams {
|
||||
}
|
||||
out.flush();
|
||||
return byteCount;
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
try {
|
||||
in.close();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
} catch (IOException ex) {
|
||||
// do nothing
|
||||
}
|
||||
try {
|
||||
out.close();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
} catch (IOException ex) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
@ -145,12 +142,10 @@ public abstract class Streams {
|
||||
Preconditions.checkNotNull(out, "No OutputStream specified");
|
||||
try {
|
||||
out.write(in);
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
try {
|
||||
out.close();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
} catch (IOException ex) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
@ -165,9 +160,9 @@ public abstract class Streams {
|
||||
* @throws IOException in case of I/O errors
|
||||
*/
|
||||
public static byte[] copyToByteArray(InputStream in) throws IOException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream(BUFFER_SIZE);
|
||||
FastByteArrayOutputStream out = FastByteArrayOutputStream.Cached.cached();
|
||||
copy(in, out);
|
||||
return out.toByteArray();
|
||||
return out.copiedByteArray();
|
||||
}
|
||||
|
||||
|
||||
@ -197,18 +192,15 @@ public abstract class Streams {
|
||||
}
|
||||
out.flush();
|
||||
return byteCount;
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
try {
|
||||
in.close();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
} catch (IOException ex) {
|
||||
// do nothing
|
||||
}
|
||||
try {
|
||||
out.close();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
} catch (IOException ex) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
@ -227,12 +219,10 @@ public abstract class Streams {
|
||||
Preconditions.checkNotNull(out, "No Writer specified");
|
||||
try {
|
||||
out.write(in);
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
try {
|
||||
out.close();
|
||||
}
|
||||
catch (IOException ex) {
|
||||
} catch (IOException ex) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
package org.elasticsearch.http.netty;
|
||||
|
||||
import org.elasticsearch.common.netty.handler.codec.http.HttpHeaders;
|
||||
import org.elasticsearch.common.netty.handler.codec.http.HttpMethod;
|
||||
import org.elasticsearch.http.HttpRequest;
|
||||
import org.elasticsearch.rest.support.AbstractRestRequest;
|
||||
@ -28,7 +27,6 @@ import org.elasticsearch.rest.support.RestUtils;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
@ -132,18 +130,10 @@ public class NettyHttpRequest extends AbstractRestRequest implements HttpRequest
|
||||
return request.getContent().toString(UTF8);
|
||||
}
|
||||
|
||||
@Override public Set<String> headerNames() {
|
||||
return request.getHeaderNames();
|
||||
}
|
||||
|
||||
@Override public String header(String name) {
|
||||
return request.getHeader(name);
|
||||
}
|
||||
|
||||
@Override public String cookie() {
|
||||
return request.getHeader(HttpHeaders.Names.COOKIE);
|
||||
}
|
||||
|
||||
@Override public boolean hasParam(String key) {
|
||||
return params.containsKey(key);
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
@ -67,12 +66,8 @@ public interface RestRequest extends ToXContent.Params {
|
||||
|
||||
String contentAsString();
|
||||
|
||||
Set<String> headerNames();
|
||||
|
||||
String header(String name);
|
||||
|
||||
String cookie();
|
||||
|
||||
boolean hasParam(String key);
|
||||
|
||||
String param(String key);
|
||||
|
@ -94,7 +94,7 @@ public class XContentRestResponse extends AbstractRestResponse {
|
||||
if (prefixUtf8Result != null) {
|
||||
return prefixUtf8Result.length;
|
||||
}
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override public byte[] suffixContent() {
|
||||
@ -108,7 +108,7 @@ public class XContentRestResponse extends AbstractRestResponse {
|
||||
if (prefixUtf8Result != null) {
|
||||
return END_JSONP.length;
|
||||
}
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static UnicodeUtil.UTF8Result startJsonp(RestRequest request) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user