/** * Decide whether the post fields should be added to the Oauth BaseString. * Flickr incorrectly add the post fields when the content type is 'multipart/form-data'. They should only be added when the content type is 'application/x-www-form-urlencoded' * * @param $request * @return bool Whether the post fields should be signed or not */ public function shouldPostFieldsBeSigned(Request $request) { $returnValue = false; if ($request->hasHeader('Content-Type')) { $contentType = $request->getHeader('Content-Type'); //TODO - not safe if ($contentType === 'application/x-www-form-urlencoded' || $contentType === 'multipart/form-data') { $returnValue = true; } } // Don't sign POST fields if the request uses POST fields and no files $body = $request->getBody(); if ($body instanceof \Amp\Artax\FormBody) { if ($body == 0) { $returnValue = false; } } return $returnValue; }
private function requestExpects100Continue(Request $request) { if (!$request->hasHeader('Expect')) { return false; } elseif (stripos(implode(',', $request->getHeader('Expect')), '100-continue') !== false) { return true; } else { return false; } }
/** * Decide whether the post fields should be added to the base string that Oauth signs. * Non-conformant APIs may require that this method be * overwritten e.g. the Flickr API incorrectly adds the post fields when the Content-Type * is 'application/x-www-form-urlencoded' * * @param $request * @return bool Whether the post fields should be signed or not */ public function shouldPostFieldsBeSigned(Request $request) { $returnValue = false; if ($request->hasHeader('Content-Type')) { $contentType = $request->getHeader('Content-Type'); //TODO - not safe if ($contentType !== 'application/x-www-form-urlencoded') { $returnValue = true; } } // Don't sign POST fields if the request uses POST fields and no files if ($request->getFileCount() == 0) { $returnValue = false; } return $returnValue; }