Plugin scripts in RAW mode
In normal mode plugin scripts should only output parts of HTML code that gets inserted into skin template that is used for rendering plugin pages.
However this prevents plugin scripts from completely controlling how the final output will look like and prevents script from being used to dynamically render other types of content - menus or images.
Plugin scripts can work in RAW mode, which means script will fully control the HTTP response that will be sent when request to plugin script is made.
Naming convention
Any plugin script file that has its name ending with .raw
suffix will be executed in RAW mode.
Script output
Output from the scripts running in RAW mode will be sent directly to the client as HTTP response. This means that the script should take care of not only printing the output file contents but also include HTTP protocol headers. This gives an option for the script to control response status and insert extra HTTP response headers.
Controlling full HTTP response allows script to implement response streaming.
Example script
Assuming there is a plugin with name hello_world
already installed. Placing the following script in /usr/local/directadmin/plugins/hello_world/user/script.raw
:
#!/bin/sh
echo "HTTP/1.1 200 OK";
echo "Content-Type: text/html";
echo "";
echo "hello world<br>";
sleep 1
echo "hello again<br>";
sleep 1
echo "and again<br>";
sleep 1
echo "and again<br>";
exit 0;
Will stream its contents line by line. Response can be tested from command line with curl
using command:
curl "$(da api-url)/CMD_PLUGINS/hello_world/script.raw"