/** * Builds the request content based on the request object. * * If the $request->body() is a string, it will be used as is. * Array data will be processed with Cake\Network\Http\FormData * * @param \Cake\Network\Http\Request $request The request being sent. * @param array $options Array of options to use. * @return void */ protected function _buildContent(Request $request, $options) { $content = $request->body(); if (empty($content)) { return; } if (is_string($content)) { $this->_contextOptions['content'] = $content; return; } if (is_array($content)) { $formData = new FormData(); $formData->addMany($content); $type = $formData->contentType(); $request->header('Content-Type', $type); $this->_contextOptions['content'] = (string) $formData; return; } $this->_contextOptions['content'] = $content; }