本文整理汇总了PHP中Guzzle\Http\Message\RequestInterface::addPostFields方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestInterface::addPostFields方法的具体用法?PHP RequestInterface::addPostFields怎么用?PHP RequestInterface::addPostFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guzzle\Http\Message\RequestInterface
的用法示例。
在下文中一共展示了RequestInterface::addPostFields方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: visit
public function visit(CommandInterface $command, RequestInterface $request, Parameter $param, $value)
{
$this->fqname = $command->getName();
$query = array();
$this->customResolver($value, $param, $query, $param->getWireName());
$request->addPostFields($query);
}
示例2: setBody
public static function setBody(RequestInterface $request, $body, $options)
{
$type = isset($options['request_type']) ? $options['request_type'] : 'form';
$header = null;
if ($type == 'form') {
// Encoding body into form-urlencoded format
return $request->addPostFields($body);
}
if ($type == 'raw') {
// Raw body
return $request->setBody($body, $header);
}
}
示例3: onRequest
protected function onRequest(ConnectionInterface $from, RequestInterface $request)
{
$requestPath = $request->getPath();
$body = (string) $request->getBody();
if (!empty($body)) {
$query = QueryString::fromString($body);
$fields = $query->getAll();
$request->addPostFields($fields);
}
// TODO: use only $req->acceptLanguage() in Managers
$_SERVER['HTTP_ACCEPT_LANGUAGE'] = (string) $request->getHeaders()->get('accept-language');
$routes = array('/' => 'executeUiBooter', '/api' => 'executeApiCall', '/api/group' => 'executeApiCallGroup', '/sbin/apicall.php' => 'executeApiCall', '/sbin/apicallgroup.php' => 'executeApiCallGroup', '/sbin/rawdatacall.php' => 'executeRawDataCall', '#^/([a-zA-Z0-9-_.]+)\\.html$#' => 'executeUiBooter', '#^/(bin|boot|etc|home|tmp|usr|var)/(.*)$#' => 'executeReadFile', '/webos.webapp' => 'executeReadManifest', '/hello' => 'executeSayHello');
foreach ($routes as $path => $method) {
$matched = false;
if (substr($path, 0, 1) == '#') {
// Regex
if (preg_match($path, $requestPath, $matches)) {
$result = $this->{$method}($from, $request, $matches);
$matched = true;
}
} else {
if ($path == $requestPath) {
$result = $this->{$method}($from, $request);
$matched = true;
}
}
if ($matched) {
if (empty($result)) {
$result = '';
}
if ($result instanceof ResponseContent) {
$result = $result->generate();
}
if ($result instanceof HTTPServerResponse) {
if ($result->headersSent()) {
// Implicit mode, content already sent
if ($result->getHeader('Connection') != 'keep-alive') {
$from->close();
}
} else {
$result->send();
}
return;
}
$response = null;
if (is_string($result)) {
$response = new Response(200, array(), (string) $result);
} else {
$response = $result;
}
$from->send((string) $response);
$from->close();
return;
}
}
$resp = new Response(404, array('Content-Type' => 'text/plain'), '404 Not Found');
$from->send((string) $resp);
$from->close();
}
示例4: configureRequest
private function configureRequest(RequestInterface $request, array $server, array $enclosure)
{
if (isset($server['HTTP_HOST'])) {
$request->setHost($server['HTTP_HOST']);
}
if (isset($server['HTTP_PORT'])) {
$request->setPort($server['HTTP_PORT']);
}
if (isset($server['PHP_AUTH_USER'])) {
$request->setAuth($server['PHP_AUTH_USER'], isset($server['PHP_AUTH_PW']) ? $server['PHP_AUTH_PW'] : null);
}
$params = [];
if (isset($server['HTTP_USER_AGENT'])) {
$params['userAgent'] = $server['HTTP_USER_AGENT'];
}
if ($request instanceof EntityEnclosingRequestInterface) {
$request->addPostFields($enclosure);
}
return $params;
}