Esempio n. 1
0
 /**
  * Creates a new request object based on the parameters.
  *
  * @param string $method HTTP method name.
  * @param string $url The url including query string.
  * @param mixed $data The request body.
  * @param array $options The options to use. Contains auth, proxy etc.
  * @return \Cake\Network\Http\Request
  */
 protected function _createRequest($method, $url, $data, $options)
 {
     $request = new Request();
     $request->method($method)->url($url)->body($data);
     if (isset($options['type'])) {
         $request->header($this->_typeHeaders($options['type']));
     }
     if (isset($options['headers'])) {
         $request->header($options['headers']);
     }
     $request->cookie($this->_cookies->get($url));
     if (isset($options['cookies'])) {
         $request->cookie($options['cookies']);
     }
     if (isset($options['auth'])) {
         $this->_addAuthentication($request, $options);
     }
     if (isset($options['proxy'])) {
         $this->_addProxy($request, $options);
     }
     return $request;
 }
Esempio n. 2
0
 /**
  * Creates a new request object based on the parameters.
  *
  * @param string $method HTTP method name.
  * @param string $url The url including query string.
  * @param mixed $data The request body.
  * @param array $options The options to use. Contains auth, proxy etc.
  * @return \Cake\Network\Http\Request
  */
 protected function _createRequest($method, $url, $data, $options)
 {
     $request = new Request();
     $request->method($method)->url($url)->body($data);
     if (isset($options['type'])) {
         $request->header($this->_typeHeaders($options['type']));
     }
     if (isset($options['headers'])) {
         $request->header($options['headers']);
     }
     if (is_string($data) && !$request->header('content-type')) {
         $request->header('Content-Type', 'application/x-www-form-urlencoded');
     }
     $request->cookie($this->_cookies->get($url));
     if (isset($options['cookies'])) {
         $request->cookie($options['cookies']);
     }
     if (isset($options['auth'])) {
         $this->_addAuthentication($request, $options);
     }
     if (isset($options['proxy'])) {
         $this->_addProxy($request, $options);
     }
     return $request;
 }