On a slow and low resource dev box I need to save terminal sessions using asciinema. I cannot afford to install the official asciinema-server. I tried to find out what is being sent to the server and save it with a small PHP script. So I created a ~/.config/asciinema/config
config file and set the api url to one on localhost.
I have a very simple script that is hit when a cast is uploaded but it seems nothing is being posted. Here is my script:
<?php
session_start();
$i = [];
$i['post'] = $_POST;
$i['get'] = $_GET;
$i['request'] = $_REQUEST;
$i['server'] = $_SERVER;
$i['cookie'] = $_COOKIE;
$i['env'] = $_ENV;
$i['files'] = $_FILES;
$i['session'] = $_SESSION;
$i['body'] = file_get_contents('php://input');
$j = json_encode($i);
$n = mt_rand(100000000, 999999999);
file_put_contents(__DIR__ . "/$n.json", $j);
And here is a captured request where I did a simple ls -la
in the terminal and uploaded the session:
{
"post": [],
"get": [],
"request": [],
"server": {
"USER": "********",
"HOME": "/home/********",
"HTTP_CONNECTION": "close",
"HTTP_AUTHORIZATION": "Basic dXNlcm5hbWU6cGFzc3dvcmQK",
"HTTP_USER_AGENT": "asciinema/2.0.0 CPython/3.6.9 Linux/5.4.0-144-generic-x86_64-with-Ubuntu-18.04-bionic",
"HTTP_HOST": "test.dev",
"HTTP_ACCEPT_ENCODING": "identity",
"SCRIPT_FILENAME": "/var/www/testbench/asciinema/api/asciicasts/index.php",
"REDIRECT_STATUS": "200",
"SERVER_NAME": "test.dev",
"SERVER_PORT": "80",
"SERVER_ADDR": "127.0.0.1",
"REMOTE_PORT": "51626",
"REMOTE_ADDR": "127.0.0.1",
"SERVER_SOFTWARE": "nginx/1.14.0",
"GATEWAY_INTERFACE": "CGI/1.1",
"REQUEST_SCHEME": "http",
"SERVER_PROTOCOL": "HTTP/1.1",
"DOCUMENT_ROOT": "/var/www/testbench",
"DOCUMENT_URI": "/asciinema/api/asciicasts/index.php",
"REQUEST_URI": "/asciinema/api/asciicasts/",
"SCRIPT_NAME": "/asciinema/api/asciicasts/index.php",
"CONTENT_LENGTH": "",
"CONTENT_TYPE": "",
"REQUEST_METHOD": "GET",
"QUERY_STRING": "",
"FCGI_ROLE": "RESPONDER",
"PHP_SELF": "/asciinema/api/asciicasts/index.php",
"PHP_AUTH_USER": "********",
"PHP_AUTH_PW": "********",
"REQUEST_TIME_FLOAT": 1678396966.030703,
"REQUEST_TIME": 1678396966
},
"cookie": [],
"env": [],
"files": [],
"session": [],
"body": ""
}
The function that uploads the cast should be this: https://github.com/asciinema/asciinema/blob/d34941cd6dc3b38fab4a48b80456722386da2725/asciinema/api.py#L40
Where else should I look for the cast data?