1
0
Fork 0
mirror of synced 2024-06-02 19:04:49 +12:00

Pass Content-Length header

This commit is contained in:
kodumbeats 2021-03-30 18:13:44 -04:00
parent c8f9bbc34b
commit 967d661a59

View file

@ -453,26 +453,34 @@ class FunctionsV1
$executionStart = \microtime(true);
$envs = \array_merge(\array_values($tmpvars), ["executionStart={$executionStart}"]);
var_dump($envs);
// var_dump($envs);
/*
* Create execution via Docker API
*/
$ch = \curl_init();
var_dump($executionStart);
\curl_setopt($ch, CURLOPT_URL, "http://localhost/containers/{$container}/exec");
\curl_setopt($ch, CURLOPT_UNIX_SOCKET_PATH, '/var/run/docker.sock');
\curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
\curl_setopt($ch, CURLOPT_POST, 1);
\curl_setopt($ch, CURLOPT_POSTFIELDS, [
"Env" => $envs,
"Cmd" => $command,
]);
$headers = array();
$headers[] = 'Content-Type: application/json';
$body = array(
"Env" => $envs,
"Cmd" => $command
);
var_dump($body);
$body = json_encode($body);
var_dump($body);
\curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
$headers = [
'Content-Type: application/json',
'Content-Length: ' . \strlen($body)
];
\curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
var_dump($headers);
$result = \curl_exec($ch);
var_dump($result);