/** * Manipulate Http Request * * @param iHttpRequest $request */ function withHttpRequest(iHttpRequest $request) { $params = \Poirot\Std\iterator_to_array($this); $body = json_encode($params); $request->setBody($body); $request->getHeaders()->set(HeaderFactory::factory('Content-Type', 'application/json')); }
/** * Manipulate Http Request * * @param iHttpRequest $request */ function withHttpRequest(iHttpRequest $request) { $params = \Poirot\Std\iterator_to_array($this); $body = http_build_query($params, null, '&'); $request->setBody($body); $request->getHeaders()->set(HeaderFactory::factory('Content-Type', 'application/x-www-form-urlencoded')); }