Skip to content

Module thc_HttpDServer

Drolla edited this page Mar 1, 2015 · 14 revisions

HTTP debug server

This module provides a tiny HTTP server that allows taking control over the THC server, for example for debugging purposes. This HTTP debug server allows running Tcl commands on the HTC server, getting device states, getting files, etc. Once the HTTP debug server is started (see <thc_HttpDServer::Start>), it accepts the following HTTP requests:

Description
help Provides help
eval Evaluates a Tcl command sequence

The HTTP requests can directly be performed from a web browser, or they can be issued by applications. Examples for HTTP requests:

 http://192.168.1.21:8085/help
 -> help: this help information
 -> eval \<TclCommand>: Evaluate a Tcl command and returns the result
 -> download \<File>: Download a file (from a browser)
 -> show \<File>: Show a file (in a browser)
 http://192.168.1.21:8085/eval array get State
 -> MotionSalon,state 0 Light2nd,state 0 MultiSalon,temp 19.5 MultiSalon,battery 60
 http://192.168.1.21:8085/eval JobsString
 -> 45s:RrdLog   45s:U_1m      2m:RrdGph1D 42m:RrdGph1W 42m:U_1h     15h:EvalSun  16h:RrdGph1M
 http://192.168.1.21:8085/file /var/thc/thc.log
 -> ...

The HTTP debug server accepts only a single HTTP connection at a time. It doesn't provide any security or authentication and should therefore be disabled in an insecure environment.


Proc: thc_HttpDServer::Start

Start the HTTP server. This command starts an HTTP server at the specified port. It accepts Tcl commands and scripts, evaluates them, and returns the result.

Parameters
Parameters Description
port HTTP port
Returns

HTTP server socket identifier

Examples
 thc_HttpDServer::Start 8085

Proc: thc_HttpDServer::Stop

Closes a running HTTP server.

Returns
Examples
 thc_HttpDServer::Stop
Clone this wiki locally