public function LingotekHttp::post in Lingotek Translation 3.1.x
Same name and namespace in other branches
- 8 src/Remote/LingotekHttp.php \Drupal\lingotek\Remote\LingotekHttp::post()
- 8.2 src/Remote/LingotekHttp.php \Drupal\lingotek\Remote\LingotekHttp::post()
- 4.0.x src/Remote/LingotekHttp.php \Drupal\lingotek\Remote\LingotekHttp::post()
- 3.0.x src/Remote/LingotekHttp.php \Drupal\lingotek\Remote\LingotekHttp::post()
- 3.2.x src/Remote/LingotekHttp.php \Drupal\lingotek\Remote\LingotekHttp::post()
- 3.3.x src/Remote/LingotekHttp.php \Drupal\lingotek\Remote\LingotekHttp::post()
- 3.4.x src/Remote/LingotekHttp.php \Drupal\lingotek\Remote\LingotekHttp::post()
- 3.5.x src/Remote/LingotekHttp.php \Drupal\lingotek\Remote\LingotekHttp::post()
- 3.6.x src/Remote/LingotekHttp.php \Drupal\lingotek\Remote\LingotekHttp::post()
- 3.7.x src/Remote/LingotekHttp.php \Drupal\lingotek\Remote\LingotekHttp::post()
- 3.8.x src/Remote/LingotekHttp.php \Drupal\lingotek\Remote\LingotekHttp::post()
Send a POST request.
Parameters
string|\Psr\Http\Message\UriInterface $path: URI object or string.
array $args: Request arguments to the POST request.
bool $use_multipart: If TRUE, use multipart post arguments. If FALSE, uses form parameters.
Return value
\Psr\Http\Message\ResponseInterface A response.
Overrides LingotekHttpInterface::post
File
- src/
Remote/ LingotekHttp.php, line 61
Class
- LingotekHttp
- Lingotek HTTP implementation using Guzzle.
Namespace
Drupal\lingotek\RemoteCode
public function post($path, $args = [], $use_multipart = FALSE) {
$options = [];
if (count($args) && $use_multipart) {
$multipart = [];
foreach ($args as $name => $contents) {
if (is_array($contents)) {
foreach ($contents as $content) {
$multipart[] = [
'name' => $name,
'contents' => $content,
];
}
}
else {
$multipart[] = [
'name' => $name,
'contents' => $contents,
];
}
}
$options[RequestOptions::MULTIPART] = $multipart;
}
elseif (count($args) && !$use_multipart) {
$options[RequestOptions::FORM_PARAMS] = $args;
}
return $this->httpClient
->post($this
->getBaseUrl() . $path, [
RequestOptions::HEADERS => $this
->getDefaultHeaders(),
] + $options);
}