Stream: variables and script. This is a port of corresponding http code with unrelated features excluded.