<p dir="auto"><strong>Elasticsearch version</strong>:</p>
<p dir="auto">2.1.1</p>
<p dir="auto"><strong>JVM version</strong>:</p>
<p dir="auto">1.8.0_60</p>
<p dir="auto"><strong>OS version</strong>:</p>
<p dir="auto">Mac OS yosemite</p>
<p dir="auto"><strong>Description of the problem including expected versus actual behavior</strong>:</p>
<p dir="auto">If I'm testing undefined analyser the request will hang, instead it should return an error.</p>
<p dir="auto"><code class="notranslate">curl -XGET 'localhost:9200/_analyze' -d ' {"analyzer" : "path_analyzer", "text" : "config/initialize/gitlab.yml" }'</code></p>
<p dir="auto"><strong>Steps to reproduce</strong>:<br>
run <code class="notranslate">curl -XGET 'localhost:9200/_analyze' -d ' {"analyzer" : "path_analyzer", "text" : "config/initialize/gitlab.yml" }'</code></p>
<p dir="auto"><strong>Provide logs (if relevant)</strong>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[2016-02-25 12:11:20,699][ERROR][transport                ] [Tomazooma] failed to handle exception for action [indices:admin/analyze[s]], handler [org.elasticsearch.action.support.single.shard.TransportSingleShardAction$AsyncSingleAction$1@1da2dd9e]
java.lang.NullPointerException
    at org.elasticsearch.action.support.single.shard.TransportSingleShardAction$AsyncSingleAction.perform(TransportSingleShardAction.java:195)
    at org.elasticsearch.action.support.single.shard.TransportSingleShardAction$AsyncSingleAction.access$700(TransportSingleShardAction.java:115)
    at org.elasticsearch.action.support.single.shard.TransportSingleShardAction$AsyncSingleAction$1.handleException(TransportSingleShardAction.java:174)
    at org.elasticsearch.transport.TransportService$DirectResponseChannel.processException(TransportService.java:821)
    at org.elasticsearch.transport.TransportService$DirectResponseChannel.sendResponse(TransportService.java:799)
    at org.elasticsearch.transport.TransportService$4.onFailure(TransportService.java:361)
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:42)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
"><pre class="notranslate"><code class="notranslate">[2016-02-25 12:11:20,699][ERROR][transport                ] [Tomazooma] failed to handle exception for action [indices:admin/analyze[s]], handler [org.elasticsearch.action.support.single.shard.TransportSingleShardAction$AsyncSingleAction$1@1da2dd9e]
java.lang.NullPointerException
    at org.elasticsearch.action.support.single.shard.TransportSingleShardAction$AsyncSingleAction.perform(TransportSingleShardAction.java:195)
    at org.elasticsearch.action.support.single.shard.TransportSingleShardAction$AsyncSingleAction.access$700(TransportSingleShardAction.java:115)
    at org.elasticsearch.action.support.single.shard.TransportSingleShardAction$AsyncSingleAction$1.handleException(TransportSingleShardAction.java:174)
    at org.elasticsearch.transport.TransportService$DirectResponseChannel.processException(TransportService.java:821)
    at org.elasticsearch.transport.TransportService$DirectResponseChannel.sendResponse(TransportService.java:799)
    at org.elasticsearch.transport.TransportService$4.onFailure(TransportService.java:361)
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:42)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

</code></pre></div>
<p dir="auto"><strong>Describe the feature</strong>:</p>
<p dir="auto">My goal is to access elasticsearch data from other domain, am I missing anything over here?</p>
<p dir="auto">I set the config in elasticsearch.yml file which looks like this</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="http.cors.enabled: true
http.cors.allow-origin: &quot;/.*/&quot;
http.cors.allow-credentials: true
http.cors.allow-headers: &quot;Authorization, X-Requested-With, Content-Type, Content-Length&quot;"><pre class="notranslate"><span class="pl-ent">http.cors.enabled</span>: <span class="pl-c1">true</span>
<span class="pl-ent">http.cors.allow-origin</span>: <span class="pl-s"><span class="pl-pds">"</span>/.*/<span class="pl-pds">"</span></span>
<span class="pl-ent">http.cors.allow-credentials</span>: <span class="pl-c1">true</span>
<span class="pl-ent">http.cors.allow-headers</span>: <span class="pl-s"><span class="pl-pds">"</span>Authorization, X-Requested-With, Content-Type, Content-Length<span class="pl-pds">"</span></span></pre></div>
<p dir="auto">after set the config I restart elasticsearch</p>
<p dir="auto">now I want to do xhr call from other domain</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://127.0.0.1:9200/_search', true);
xhr.withCredentials = true;
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('Authorization', 'Basic ' + btoa('admin:admin'));
xhr.send('{&quot;query&quot;:{&quot;match_all&quot;:{}}}');"><pre class="notranslate"><span class="pl-k">var</span> <span class="pl-s1">xhr</span> <span class="pl-c1">=</span> <span class="pl-k">new</span> <span class="pl-v">XMLHttpRequest</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-s1">xhr</span><span class="pl-kos">.</span><span class="pl-en">open</span><span class="pl-kos">(</span><span class="pl-s">'POST'</span><span class="pl-kos">,</span> <span class="pl-s">'http://127.0.0.1:9200/_search'</span><span class="pl-kos">,</span> <span class="pl-c1">true</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-s1">xhr</span><span class="pl-kos">.</span><span class="pl-c1">withCredentials</span> <span class="pl-c1">=</span> <span class="pl-c1">true</span><span class="pl-kos">;</span>
<span class="pl-s1">xhr</span><span class="pl-kos">.</span><span class="pl-en">setRequestHeader</span><span class="pl-kos">(</span><span class="pl-s">'Content-Type'</span><span class="pl-kos">,</span> <span class="pl-s">'application/json'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-s1">xhr</span><span class="pl-kos">.</span><span class="pl-en">setRequestHeader</span><span class="pl-kos">(</span><span class="pl-s">'Authorization'</span><span class="pl-kos">,</span> <span class="pl-s">'Basic '</span> <span class="pl-c1">+</span> <span class="pl-en">btoa</span><span class="pl-kos">(</span><span class="pl-s">'admin:admin'</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-s1">xhr</span><span class="pl-kos">.</span><span class="pl-en">send</span><span class="pl-kos">(</span><span class="pl-s">'{"query":{"match_all":{}}}'</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">It responds with following error</p>
<p dir="auto">XMLHttpRequest cannot load <a href="http://127.0.0.1:9200/_search" rel="nofollow">http://127.0.0.1:9200/_search</a>. Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response.</p>