Issue #2537602 by hchonov, dawehner: JQuery ajax GET requests result in "406 Not Acceptable"
parent
9fb5187d43
commit
76ecf77f31
|
@ -37,10 +37,6 @@ class ContentNegotiation {
|
|||
return $request->query->get('_format');
|
||||
}
|
||||
|
||||
if ($request->isXmlHttpRequest()) {
|
||||
return 'ajax';
|
||||
}
|
||||
|
||||
// Do HTML last so that it always wins.
|
||||
return 'html';
|
||||
}
|
||||
|
|
|
@ -1555,7 +1555,15 @@ abstract class WebTestBase extends TestBase {
|
|||
if (!isset($options['query'][MainContentViewSubscriber::WRAPPER_FORMAT])) {
|
||||
$options['query'][MainContentViewSubscriber::WRAPPER_FORMAT] = 'drupal_ajax';
|
||||
}
|
||||
return Json::decode($this->drupalGet($path, $options, $headers));
|
||||
return Json::decode($this->drupalGetXHR($path, $options, $headers));
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests a Drupal path as if it is a XMLHttpRequest.
|
||||
*/
|
||||
protected function drupalGetXHR($path, array $options = array(), array $headers = array()) {
|
||||
$headers[] = 'X-Requested-With: XMLHttpRequest';
|
||||
return $this->drupalGet($path, $options, $headers);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -94,6 +94,10 @@ class DialogTest extends AjaxTestBase {
|
|||
$this->drupalGet('ajax-test/dialog-contents');
|
||||
$this->assertRaw($dialog_contents, 'Non-JS modal dialog page present.');
|
||||
|
||||
// Check that requesting a modal dialog with XMLHttpRequest goes to a page.
|
||||
$this->drupalGetXHR('ajax-test/dialog-contents');
|
||||
$this->assertRaw($dialog_contents, 'Modal dialog page on XMLHttpRequest present.');
|
||||
|
||||
// Emulate going to the JS version of the page and check the JSON response.
|
||||
$ajax_result = $this->drupalGetAjax('ajax-test/dialog-contents', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal')));
|
||||
$this->assertEqual($modal_expected_response, $ajax_result[3], 'Modal dialog JSON response matches.');
|
||||
|
|
|
@ -73,7 +73,7 @@ class ContentNegotiationTest extends UnitTestCase {
|
|||
$request = new Request();
|
||||
$request->headers->set('X-Requested-With', 'XMLHttpRequest');
|
||||
|
||||
$this->assertSame('ajax', $this->contentNegotiation->getContentType($request));
|
||||
$this->assertSame('html', $this->contentNegotiation->getContentType($request));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue