HTTP server

Description
x3270 supports an HTTP server. Scripts can send REST requests to x3270 via HTTP to modify the emulator or query its state.

A global HTTP server is configured via the httpd resource. The Script action supports an -Http option to create a new instance of the HTTP server for the script to use.

For experimentation, the HTTP server can be used from an ordinary web browser. Just point your browser at the root (e.g., http://127.0.0.1:8080/ ) and appropriate directories will be displayed.

Namespace
These examples assume that the server is set up to listen on port 8080.
 * http://127.0.0.1:8080/3270/interact.html
 * An interactive form for submitting actions to the emulator.


 * http://127.0.0.1:8080/3270/screen.html
 * The current screen image.


 * http://127.0.0.1:8080/3270/rest/json/
 * REST API with results returned as JSON.


 * http://127.0.0.1:8080/3270/rest/html/
 * REST API with results returned as HTML.


 * http://127.0.0.1:8080/3270/rest/text/
 * REST API with results returned as plain text.


 * http://127.0.0.1:8080/3270/rest/stext/
 * REST API with results returned as plain text, beginning with the status line.

REST API
Requests use the HTTP GET verb. Simply add the x3270 action and parameters to the desired URL. For example, to perform the Query action with the Proxies parameter with the response in HTML, use this URL: http://127.0.0.1:8080/3270/rest/html/Query(Proxies)

JSON results
GET: http://127.0.0.1:8080/3270/rest/json/Query(Proxies) Result: { "status": "L U U N N 4 24 80 0 0 0x0 0.000", "result": [ "passthru no-username 3514", "http username 3128", "telnet no-username", "socks4 username 1080", "socks4a username 1080", "socks5 username 1080", "socks5d username 1080" ] }

HTML results
GET: http://127.0.0.1:8080/3270/rest/html/Query(Proxies) Result: &lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> &lt;html> &lt;head> &lt;title>Success&lt;/title> &lt;/head> &lt;body> &lt;h1>Success&lt;/h1> &lt;h2>Status&lt;/h2> &lt;pre>L U U N N 4 24 80 0 0 0x0 0.000&lt;/pre> &lt;h2>Result&lt;/h2> &lt;pre>passthru no-username 3514 http username 3128 telnet no-username socks4 username 1080 socks4a username 1080 socks5 username 1080 socks5d username 1080 &lt;/pre> &lt;hr> &lt;i>wc3270 v4.0alpha2 Sat Dec 28 05:26:41 UTC 2019 pdm - &lt;a href="http://x3270.bgp.nu/">x3270.bgp.nu&lt;/a>&lt;/i> &lt;/body> &lt;/html> &lt;/pre>

Plain text with status line results
GET: http://127.0.0.1:8080/3270/rest/stext/Query(Proxies) Result: L U U N N 4 24 80 0 0 0x0 0.000 passthru no-username 3514 http username 3128 telnet no-username socks4 username 1080 socks4a username 1080 socks5 username 1080 socks5d username 1080

Plain text results
GET: http://127.0.0.1:8080/3270/rest/text/Query(Proxies) Result: passthru no-username 3514 http username 3128 telnet no-username socks4 username 1080 socks4a username 1080 socks5 username 1080 socks5d username 1080