title: POST request XML with CakePHP
body: <p>I'm trying to make a POST request of XML data with CakePHP 2.3.8, but I'm having some issues and I think it's dealing with authorization. First of all, what I'm trying to do is make a POST request with XML data from an action in a controller. The action which this post request is made to should save an entry in the database, just so I know that the POST request was successfully triggered. Nothing is being saved.</p>
  
  <p>Here are the two actions and the beforefilter. I made sure to allow access to every action in the beforefilter. xml_post is the action that I visit which triggers the XML post request, and the receive_xml action is the one that should save an entry in the database when something is received.</p>
  
  <pre><code>public function beforeFilter() {
      parent::beforeFilter();
      $this-&gt;Auth-&gt;authorize = 'Controller';  
      $this-&gt;Auth-&gt;allow = array('*');
  }
  
  public function xml_post_test(){
      $data = array(
          'post' =&gt; array(
              'id' =&gt; 1,
              'title' =&gt; 'This is a test',
              'body' =&gt; 'Here is something for the body '
          )
      );
  
      App::uses('HttpSocket', 'Network/Http');
      $http = new HttpSocket();
      $xml_data = Xml::fromArray($data);
      $xml_string = $xml_data-&gt;asXML();
      $response = $http-&gt;post('http://localhost/tests/receive_xml', $xml_string);
      debug($response);
  }
  
      //save an arbitrary entry in the database a POST request is received (just checking that the xml_post_test method is working
  public function receive_xml(){
          if($this-&gt;request-&gt;is('post')){
              $this-&gt;loadmodel('TestTable');
              $this-&gt;TestTable-&gt;create();
              $this-&gt;TestTable-&gt;save(array('id' =&gt; '','data' =&gt; 'abc 123'));
          }
  }
  </code></pre>
  
  <p>Here is the response (debug)</p>
  
  <pre><code>object(HttpSocketResponse) {
      body =&gt; ''
      headers =&gt; array(
          'Date' =&gt; 'Mon, 07 Apr 2014 02:28:15 GMT',
          'Server' =&gt; 'Apache/2.4.4 (Unix) PHP/5.4.19 OpenSSL/1.0.1e mod_perl/2.0.8-dev Perl/v5.16.3',
          'X-Powered-By' =&gt; 'PHP/5.4.19',
          'Set-Cookie' =&gt; 'CAKEPHP=ddb8lvdvmqvrce9ve2eo5e61l5; expires=Mon, 07-Apr-2014 06:28:15 GMT; path=/; HttpOnly',
          'Location' =&gt; 'http://localhost/users/login',
          'Content-Length' =&gt; '0',
          'Connection' =&gt; 'close',
          'Content-Type' =&gt; 'text/html; charset=UTF-8'
      )
      cookies =&gt; array(
          'CAKEPHP' =&gt; array(
              'value' =&gt; 'ddb8lvdvmqvrce9ve2eo5e61l5',
              'expires' =&gt; 'Mon, 07-Apr-2014 06:28:15 GMT',
              'path' =&gt; '/',
              'httponly' =&gt; true
          )
      )
      httpVersion =&gt; 'HTTP/1.1'
      code =&gt; '302'
      reasonPhrase =&gt; 'Found'
      raw =&gt; 'HTTP/1.1 302 Found
  Date: Mon, 07 Apr 2014 02:28:15 GMT
  Server: Apache/2.4.4 (Unix) PHP/5.4.19 OpenSSL/1.0.1e mod_perl/2.0.8-dev Perl/v5.16.3
  X-Powered-By: PHP/5.4.19
  Set-Cookie: CAKEPHP=ddb8lvdvmqvrce9ve2eo5e61l5; expires=Mon, 07-Apr-2014 06:28:15 GMT; path=/; HttpOnly
  Location: http://localhost/users/login
  Content-Length: 0
  Connection: close
  Content-Type: text/html; charset=UTF-8
  
  '
      context =&gt; array()
  }
  </code></pre>