Beispiel #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\Http\Client\Request
  */
 protected function _createRequest($method, $url, $data, $options)
 {
     $headers = isset($options['headers']) ? (array) $options['headers'] : [];
     if (isset($options['type'])) {
         $headers = array_merge($headers, $this->_typeHeaders($options['type']));
     }
     if (is_string($data) && !isset($headers['Content-Type']) && !isset($headers['content-type'])) {
         $headers['Content-Type'] = 'application/x-www-form-urlencoded';
     }
     $request = new Request($url, $method, $headers, $data);
     $request->cookie($this->_cookies->get($url));
     if (isset($options['cookies'])) {
         $request->cookie($options['cookies']);
     }
     if (isset($options['auth'])) {
         $request = $this->_addAuthentication($request, $options);
     }
     if (isset($options['proxy'])) {
         $request = $this->_addProxy($request, $options);
     }
     return $request;
 }