lithium\net\http\Service::_request()

protected method

Instantiates a request object (usually an instance of http\Request) and tests its properties based on the request type and data to be sent.

Parameters

  • string $method

    The HTTP method of the request, i.e. 'GET', 'HEAD', 'OPTIONS', etc. Can be passed in upper- or lower-case.

  • string $path

    The

  • string $data
  • string $options

Returns

object

Returns an instance of http\Request, configured with an HTTP method, query string or POST/PUT/PATCH data, and URL.

Source

	protected function _request($method, $path, $data, $options) {
		$defaults = ['type' => 'form'];
		$options += $defaults + $this->_config;

		$request = Libraries::instance(null, 'request', $options, $this->_classes);
		$request->path = str_replace('//', '/', "{$request->path}{$path}");
		$request->method = $method = strtoupper($method);
		$hasBody = in_array($method, ['POST', 'PUT', 'PATCH']);
		$hasBody ? $request->body($data) : $request->query = $data;
		return $request;
	}