@Test
public void xhrPollingTestRequestHeadersCors() throws Exception {
final SockJsServiceFactory echoFactory = echoService();
final String sessionUrl = echoFactory.config().prefix() + "/abc/" + UUID.randomUUID().toString();
final FullHttpRequest okRequest = httpRequest(sessionUrl + "/xhr", POST);
okRequest.headers().set(ACCESS_CONTROL_REQUEST_HEADERS, "a, b, c");
final HttpResponse response = xhrRequest(okRequest, echoFactory);
assertThat(response.getStatus(), is(HttpResponseStatus.OK));
SockJsTestUtil.assertCORSHeaders(response, "*");
assertThat(response.headers().get(ACCESS_CONTROL_ALLOW_HEADERS), equalTo("a, b, c"));
final String emptySessionUrl = echoFactory.config().prefix() + "/abc/" + UUID.randomUUID().toString();
final FullHttpRequest emptyHeaderRequest = httpRequest(emptySessionUrl + "/xhr", POST);
emptyHeaderRequest.headers().set(ACCESS_CONTROL_REQUEST_HEADERS, "");
final HttpResponse emptyHeaderResponse = xhrRequest(emptyHeaderRequest, echoFactory);
assertThat(emptyHeaderResponse.getStatus(), is(HttpResponseStatus.OK));
SockJsTestUtil.assertCORSHeaders(response, "*");
assertThat(emptyHeaderResponse.headers().get(ACCESS_CONTROL_ALLOW_HEADERS), is(nullValue()));
final String noHeaderSessionUrl = echoFactory.config().prefix() + "/abc/" + UUID.randomUUID().toString();
final FullHttpRequest noHeaderRequest = httpRequest(noHeaderSessionUrl + "/xhr", POST);
final HttpResponse noHeaderResponse = xhrRequest(noHeaderRequest, echoFactory);
assertThat(noHeaderResponse.getStatus(), is(HttpResponseStatus.OK));
SockJsTestUtil.assertCORSHeaders(response, "*");
assertThat(noHeaderResponse.headers().get(ACCESS_CONTROL_ALLOW_HEADERS), is(nullValue()));
}