reindex from remote to read content-type header rather than guessing content type based on content
This commit is contained in:
parent
54fa997545
commit
bce54cf38d
|
@ -34,9 +34,8 @@ import org.elasticsearch.common.bytes.BytesReference;
|
|||
import org.elasticsearch.common.logging.ESLogger;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
|
||||
import org.elasticsearch.common.xcontent.XContent;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.reindex.ScrollableHitSource;
|
||||
import org.elasticsearch.rest.RestStatus;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
|
@ -141,8 +140,9 @@ public class RemoteScrollableHitSource extends ScrollableHitSource {
|
|||
T parsedResponse;
|
||||
try {
|
||||
InputStream content = response.getEntity().getContent();
|
||||
XContent xContent = XContentFactory.xContentType(content).xContent();
|
||||
try(XContentParser xContentParser = xContent.createParser(content)) {
|
||||
XContentType xContentType = XContentType.fromMediaTypeOrFormat(
|
||||
response.getEntity().getContentType().getValue());
|
||||
try(XContentParser xContentParser = xContentType.xContent().createParser(content)) {
|
||||
parsedResponse = parser.apply(xContentParser, () -> ParseFieldMatcher.STRICT);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.apache.http.HttpResponse;
|
|||
import org.apache.http.ProtocolVersion;
|
||||
import org.apache.http.StatusLine;
|
||||
import org.apache.http.concurrent.FutureCallback;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.InputStreamEntity;
|
||||
import org.apache.http.impl.nio.client.CloseableHttpAsyncClient;
|
||||
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
|
||||
|
@ -360,7 +361,7 @@ public class RemoteScrollableHitSourceTests extends ESTestCase {
|
|||
} else {
|
||||
StatusLine statusLine = new BasicStatusLine(protocolVersion, 200, "");
|
||||
HttpResponse httpResponse = new BasicHttpResponse(statusLine);
|
||||
httpResponse.setEntity(new InputStreamEntity(resource.openStream()));
|
||||
httpResponse.setEntity(new InputStreamEntity(resource.openStream(), ContentType.APPLICATION_JSON));
|
||||
futureCallback.completed(httpResponse);
|
||||
}
|
||||
return null;
|
||||
|
|
Loading…
Reference in New Issue