mirror of https://github.com/apache/lucene.git
SOLR-8501: Specify the entity request size when known in HttpSolrClient.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1724612 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6b850bca1d
commit
32fc5285f6
|
@ -393,6 +393,11 @@ Bug Fixes
|
||||||
* SOLR-8453: Solr should attempt to consume the request inputstream on errors as we cannot
|
* SOLR-8453: Solr should attempt to consume the request inputstream on errors as we cannot
|
||||||
count on the container to do it. (Mark Miller, Greg Wilkins, yonik, Joakim Erdfelt)
|
count on the container to do it. (Mark Miller, Greg Wilkins, yonik, Joakim Erdfelt)
|
||||||
|
|
||||||
|
Optimizations
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
* SOLR-8501: Specify the entity request size when known in HttpSolrClient. (Mark Miller)
|
||||||
|
|
||||||
Other Changes
|
Other Changes
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -435,7 +435,8 @@ public class HttpSolrClient extends SolrClient {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (contentStream[0] instanceof RequestWriter.LazyContentStream) {
|
if (contentStream[0] instanceof RequestWriter.LazyContentStream) {
|
||||||
postOrPut.setEntity(new InputStreamEntity(contentStream[0].getStream(), -1) {
|
Long size = contentStream[0].getSize();
|
||||||
|
postOrPut.setEntity(new InputStreamEntity(contentStream[0].getStream(), size == null ? -1 : size) {
|
||||||
@Override
|
@Override
|
||||||
public Header getContentType() {
|
public Header getContentType() {
|
||||||
return new BasicHeader("Content-Type", contentStream[0].getContentType());
|
return new BasicHeader("Content-Type", contentStream[0].getContentType());
|
||||||
|
@ -448,7 +449,8 @@ public class HttpSolrClient extends SolrClient {
|
||||||
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
postOrPut.setEntity(new InputStreamEntity(contentStream[0].getStream(), -1) {
|
Long size = contentStream[0].getSize();
|
||||||
|
postOrPut.setEntity(new InputStreamEntity(contentStream[0].getStream(), size == null ? -1 : size) {
|
||||||
@Override
|
@Override
|
||||||
public Header getContentType() {
|
public Header getContentType() {
|
||||||
return new BasicHeader("Content-Type", contentStream[0].getContentType());
|
return new BasicHeader("Content-Type", contentStream[0].getContentType());
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
@ -150,7 +151,12 @@ public abstract class ContentStreamBase implements ContentStream
|
||||||
this.str = str;
|
this.str = str;
|
||||||
this.contentType = contentType;
|
this.contentType = contentType;
|
||||||
name = null;
|
name = null;
|
||||||
size = new Long( str.length() );
|
try {
|
||||||
|
size = new Long( str.getBytes(DEFAULT_CHARSET).length );
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
// won't happen
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
sourceInfo = "string";
|
sourceInfo = "string";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue