<?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> <html class="client-nojs" dir="ltr" lang="en"> <head> <meta charset="UTF-8" /> <title>Modules/HTTP - OpenSCADAWiki</title> <meta content="MediaWiki 1.26.4" name="generator" /> <link href="https://www.gnu.org/copyleft/fdl.html" rel="copyright" /> <link href="../files/doc.css" rel="stylesheet" /></head> <body><div class="floatright"><a href="../index.html"><img alt="OpenSCADA" src="../../en/files/index.png" /></a></div><div id="mw_header"> <div class="mw-indicators"> </div> <h1 id="firstHeading" lang="en">Modules/HTTP</h1> </div><div class="mw-content-ltr" dir="ltr" id="mw-content-text" lang="en"><div class="mw-pt-languages" dir="ltr" lang="en"><div class="mw-pt-languages-list autonym"><span class="mw-pt-languages-ui mw-pt-languages-selected mw-pt-progress mw-pt-progress--complete">English</span> • ‎<a class="mw-pt-progress mw-pt-progress--complete" href="../../ru/Modules/HTTP.html" title="Модули/HTTP (81% translated)">mRussian</a> • ‎<a class="mw-pt-progress mw-pt-progress--complete" href="../../uk/Modules/HTTP.html" title="Модулі/HTTP (100% translated)">УкраїнÑька</a></div></div> <table class="wikitable"> <tr> <th> Module </th> <th> Name </th> <th> Version </th> <th> License </th> <th> Source </th> <th> Languages </th> <th> Platforms </th> <th> Type </th> <th> Author </th> <th> Description </th></tr> <tr> <td> <a href="../Modules/HTTP.html" title="Special:MyLanguage/Modules/HTTP">HTTP</a> </td> <td> HTTP-realization </td> <td> 3.9 </td> <td> GPL2 </td> <td> prot_HTTP.so </td> <td> en,uk,ru,de </td> <td> x86,x86_64,ARM </td> <td> Protocol </td> <td> Roman Savochenko<br /> <font size="-2"><i>Maxim Lysenko (2009) — the page initial translation</i></font> </td> <td> Provides support for the HTTP protocol for WWW-based user interfaces. <ul><li> <b><a href="../To_do.html" title="Special:MyLanguage/Works/To do">To Do</a>:</b></li></ul> <p><br /> </p> </td></tr></table> <p>Module of the transport protocol HTTP is designed to support the implementation of the network protocol HTTP (Hypertext Transfer Protocol) in OpenSCADA. </p><p>HTTP protocol is used to transfer the WWW content. For example, via HTTP the following types of documents are transmitted: html, xhtml, png, javascript, and many others. Support HTTP in OpenSCADA together with the transport <a href="../Modules/Sockets.html" title="Special:MyLanguage/Modules/Sockets">Sockets</a> and <a href="../Modules/SSL.html" title="Special:MyLanguage/Modules/SSL">SSL</a> allows to implement various user functions based on the WWW interface. The module initially implements two main methods of the HTTP protocol "GET", "POST", and currently any HTTP method. The module provides control of the integrity of HTTP-queries and, jointly with Sockets and SSL transport, allows to "collect" whole requests from their fragments, as well as hold of the connection "alive" (Keep-Alive). </p><p>For flexible connection of the user interfaces to this module, the modular mechanism within the module itself is used. In the role of modules the modules of the subsystem "User interfaces" are used with the additional information field "SubType", with the value of "WWW". </p><p>In the requests for the Web resources the URL(Universal Resource Locator) are commonly used. Hence, the URL is passed as the main parameter via HTTP. The first element of the requested URL is used to identify the module UI. For example, the URL "http://localhost:10002/WebCfg" means requesting to the module "WebCfg" on the host "http://localhost:10002". In the case of an incorrect indication of the module ID, or when you address without identifier of the module at all, the module generates the information dialogue on the entry and the choice of one of the available user interfaces. Example of the dialogue is shown in Figure 1. </p> <div class="center"><div class="thumb tnone"><div class="thumbinner" style="width:629px;"><a class="image" href="http://oscada.org/wiki/File:HTTP_select.png"><img class="thumbimage" height="456" src="../files/HTTP_select.png" width="627" /></a> <div class="thumbcaption">Fig.1. Dialogue of the WWW-interface module choice.</div></div></div></div> <p>The module supports multi-language which one enabled by the <a class="external" href="http://oscada.org/wiki/Documents/Program_manual#ConfigTr" title="Documents/Program manual">dynamic messages translation of OpenSCADA</a>. </p><p>The language of the final user interface is determined by and in sequence: </p> <ul><li> URL's parameter "lang".</li> <li> Authenticated user's language.</li> <li> Language of the Web-browser from the HTTP property "Accept-Language".</li> <li> Generic language of the OpenSCADA process.</li></ul> <p>Gotten in the way language used for building interfaces of the module and passes to the WWW sub-modules into the HTTP property "oscd_lang" of the argument "vars" of <a href="#ModsHTTP">the generic, "GET" and "POST" functions</a>. </p><p>To configure and control this module, you have the configuration page of the OpenSCADA control interface (Fig.3) where you can perform: </p> <ul><li> Control for the active authentication sessions.</li> <li> Configuring: <ul><li> Rules of accessing for deny and allow. Any line of the rules of accessing is a different rule and you can use here templates, like to "*/WebVision/*"), or regular expressions, like to "/[^/]+/WebVision/.+/". Useful entries for: <ul><li> Deny: <ul><li> "*/WebCfgD/*" — <a href="../Modules/WebCfgD.html" title="Special:MyLanguage/Modules/WebCfgD">the module WebCfgD</a> completely;</li> <li> "*/WebVision/*tmplSO/*" — the VCA project "tmplSO" of <a href="../Modules/WebVision.html" title="Special:MyLanguage/Modules/WebVision">the module WebVision</a>.</li></ul></li> <li> Allow: <ul><li> "*" — all, excluding the deny;</li> <li> "/^[^/]+/[^/]*$/" — pages of the module with all their resources;</li> <li> "*/login/*" — the login page;</li> <li> "/^[^/]+/WebVision/[^/]*($|\?)/" — <a href="../Modules/WebVision.html" title="Special:MyLanguage/Modules/WebVision">the WebVision module</a> main page without the VCA projects accessing;</li> <li> "/^[^/]+/WebVision/.+_aviariesOril\d*/.*/" — the VCA project "aviariesOril" of <a href="../Modules/WebVision.html" title="Special:MyLanguage/Modules/WebVision">the module WebVision</a>.</li></ul></li></ul></li> <li> HTML-template of the user interface and user main-page. In the HTML-template's fields you must specify an address of the file HTML/XHTML, which will be used for formation of the internal-service and main-page interfaces. Internal-service interfaces for example, it's the WEB-modules selection, the login page and like ones of the WEB-modules. From the template required correct XHTML, allowing parse the file by XML-parser, and the presence of the tag "#####CONTEXT#####" at the location of the dynamic content, for internal-service interfaces it's necessarily. Resource files of the templates represented by images, CSS and JavaScript files and their are searching from the directory in which located the specified template file and from the current directory. If errors are found in the template there will be use a standard builtin interface. For different, to the language, template file you can add the language suffix to the file end like "{My template}_{lang}.html" but select the generic-base template file "{My template}.html" into these configuration fields. For the templates example you can see to the most used templates: <ul><li> <a class="external" href="http://oscada.org/wiki/File:HTTP_webopenscada.html.gz" title="File:HTTP webopenscada.html.gz">Internal-service and main-page interfaces template, includes the modules index</a>.</li> <li> <a class="external" href="http://oscada.org/wiki/File:HTTP_webopenscada_main.html.gz" title="File:HTTP webopenscada main.html.gz">Main-page's template</a> with a direct link to the <a class="external" href="http://oscada.org/wiki/Special:MyLanguage/Using/Model_AGLKS" title="Special:MyLanguage/Using/Model AGLKS">AGLKS</a> main interface by <a href="../Modules/WebVision.html" title="Special:MyLanguage/Modules/WebVision">UI.WebVision</a> and without the WEB-modules index.</li> <li> <a class="external" href="http://oscada.org/wiki/File:HTTP_webopenscada_goto.html.gz" title="File:HTTP webopenscada goto.html.gz">Main-page's template</a> with a strong redirection to the <a class="external" href="http://oscada.org/wiki/Special:MyLanguage/Using/Model_AGLKS" title="Special:MyLanguage/Using/Model AGLKS">AGLKS</a> main interface by <a href="../Modules/WebVision.html" title="Special:MyLanguage/Modules/WebVision">UI.WebVision</a>.</li></ul></li> <li> DB of the active authentication sessions provides an external table of the active authentication sessions — "HTTP_AuthSessions", which is enabled for not empty value and provides a possibility of sharing the authentication between different OpenSCADA stations and its short storing at the station shut down time.</li> <li> Authentication UID generation space, accessible with the common authentication sessions table to guaranty the cookie difference for different OpenSCADA processes.</li> <li> Lifetime of the authentication, list of the users allowed for authentication and set up of the automatic login. </li></ul></li></ul> <div class="center"><div class="thumb tnone"><div class="thumbinner" style="width:784px;"><a class="image" href="http://oscada.org/wiki/File:HTTP_mod.png"><img class="thumbimage" height="774" src="../files/HTTP_mod.png" width="782" /></a> <div class="thumbcaption">Fig.3. The module configuring page.</div></div></div></div> <div class="toc" id="toc"><div id="toctitle"><h2>Contents</h2></div> <ul> <li class="toclevel-1 tocsection-1"><a href="#Authentication"><span class="tocnumber">1</span> <span class="toctext">Authentication</span></a></li> <li class="toclevel-1 tocsection-2"><a href="#Modules_of_the_WEB-interface"><span class="tocnumber">2</span> <span class="toctext"><span>Modules of the WEB-interface</span></span></a></li> <li class="toclevel-1 tocsection-3"><a href="#Function_of_the_output_requests_of_the_user_API"><span class="tocnumber">3</span> <span class="toctext">Function of the output requests of the user API</span></a></li> <li class="toclevel-1 tocsection-4"><a href="#User_programming_API"><span class="tocnumber">4</span> <span class="toctext">User programming API</span></a></li> </ul> </div> <h2><span class="mw-headline" id="Authentication"><span class="mw-headline-number">1</span> Authentication</span></h2> <p>The module supports authentication in OpenSCADA while providing access to the WEB-interface modules (Fig.2). </p> <div class="center"><div class="thumb tnone"><div class="thumbinner" style="width:619px;"><a class="image" href="http://oscada.org/wiki/File:HTTP_auth.png"><img class="thumbimage" height="302" src="../files/HTTP_auth.png" width="617" /></a> <div class="thumbcaption">Fig.2. Authentication dialogue in OpenSCADA.</div></div></div></div> <p>The authentication by the module is provided by the cookies with the dynamic name and the User ID space, where the cookie name is "oscd_UID" and is used the User ID space in work with the common authentication sessions table, and the cookie name is "oscd_UID_{PrjNm}" in the work without that. </p><p>To facilitate with Web-based interfaces, the module provides for automatic login from the specified user's name. Configuring for the automatic login makes by the module settings page (Fig.3). Automatic login performs by matching the address indicated in the column "Address", and on behalf of the user specified in the column "User". </p><p>For greater security, you can only identify Web users in the list of users allowed to authenticate. </p> <h2><span class="mw-headline" id="Modules_of_the_WEB-interface"><span class="mw-headline-number">2</span> <span id="ModsHTTP" title="#ModsHTTP">Modules of the WEB-interface</span></span></h2> <p>Modules of the user interface (UI) designed to work with the HTTP module, should indicate the information field "SubType" in the value "WWW" and "Auth" field in the value "1", if the module requires an authentication at login. For communication of the HTTP module and the UI modules an advanced communication mechanism is used. This mechanism involves export of interface functions. In this case, the UI modules must export only one generic function for all methods: </p> <ul><li> <b>void HTTP(const string &meth, const string &uri, string &page, vector<string> &vars, const string &user, TProtocolIn *iprt);</b>:</li></ul> <dl><dd><dl><dd><i>meth</i> — method of the request;</dd> <dd><i>uri</i> — local address of the request;</dd> <dd><i>page</i> — page with the answer;</dd> <dd><i>sender</i> — address of the sender;</dd> <dd><i>vars</i> — variables of the request;</dd> <dd><i>user</i> — user, can contain previous user in the second line;</dd> <dd><i>iprt</i> — pointer to an input part object of the protocol.</dd></dl></dd></dl> <p>Or following different functions separately for GET and POST methods: </p> <ul><li> <b>void HTTP_GET(const string &uri, string &page, vector<string> &vars, const string &user, TProtocolIn *iprt);</b> OR</li></ul> <dl><dd><b>void HttpGet( const string &uri, string &page, const string &sender, vector<string> &vars, const string &user );</b> — GET method with the parameters: <dl><dd><i>uri</i> — local address of the request;</dd> <dd><i>page</i> — page with the answer;</dd> <dd><i>sender</i> — address of the sender;</dd> <dd><i>vars</i> — variables of the request;</dd> <dd><i>user</i> — user, can contain previous user in the second line;</dd> <dd><i>iprt</i> — pointer to an input part object of the protocol.</dd></dl></dd></dl> <ul><li> <b>void HTTP_POST(const string &uri, string &page, vector<string> &vars, const string &user, TProtocolIn *iprt);</b> OR</li></ul> <dl><dd><b>void HttpPost( const string &uri, string &page, const string &sender, vector<string> &vars, const string &user );</b> — POST method with the parameters: <dl><dd><i>uri</i> — local address of the request;</dd> <dd><i>page</i> — page with the answer and with the content of the body of the POST request;</dd> <dd><i>sender</i> — address of the sender;</dd> <dd><i>vars</i> — variables of the request;</dd> <dd><i>user</i> — user, can contain previous user in the second line;</dd> <dd><i>iprt</i> — pointer to an input part object of the protocol.</dd></dl></dd></dl> <p>Then, in the case of the HTTP "GET" request, the function "HTTP_GET" or "HttpGet" will be called, and in the case of the "POST" request, the function "HTTP_POST" or "HttpPost" will be called in the appropriate UI module, or the function "HTTP" for any method. </p> <h2><span class="mw-headline" id="Function_of_the_output_requests_of_the_user_API"><span class="mw-headline-number">3</span> Function of the output requests of the user API</span></h2> <p>The output request function <a href="../User_API.html#SYSTransport" title="Special:MyLanguage/Documents/User API">messIO()</a> operates the exchange of contents of HTTP requests wrapped in XML packets. The query structure has the form: </p> <div class="mw-highlight mw-content-ltr" dir="ltr"><pre><span class="nt"><req</span> <span class="na">Host=</span><span class="s">"host"</span> <span class="na">URI=</span><span class="s">"uri"</span><span class="nt">></span> <span class="nt"><prm</span> <span class="na">id=</span><span class="s">"pId"</span><span class="nt">></span>pVal<span class="nt"></prm></span> <span class="nt"><cnt</span> <span class="na">name=</span><span class="s">"cName"</span> <span class="na">filename=</span><span class="s">"cFileName"</span><span class="nt">></span> <span class="nt"><prm</span> <span class="na">id=</span><span class="s">"cpId"</span><span class="nt">></span>cpVal<span class="nt"></prm></span> cVal <span class="nt"></cnt></span> reqVal <span class="nt"></req></span> </pre></div> <dl><dd>Where: <ul><li> <i>req</i> — request method, supported methods "GET" and "POST".</li> <li> <i>host</i> — http-server address in the format <i>{HostAddr}:{HostIp}</i>. If this field is omitted, then the host address specified in the transport address field is used.</li> <li> <i>uri</i> — resource address at the http server, file or directory.</li> <li> <i>pId</i>, <i>pVal</i> — identifier and value of addition http-parameters. You can set multiply http-parameters setting different <i>prm</i> tags.</li> <li> <i>cName</i>, <i>cFileName</i>, <i>cVal</i> — name, file-name and value of the content-element of the POST-request. You can set multiply content-elements setting different <i>cnt</i> tags.</li> <li> <i>cpId</i>, <i>cpVal</i> — identifier and value of addition content-parameters. You can set multiply content-parameters setting different <i>prm</i> tags;</li> <li> <i>reqVal</i> — single content of the POST request.</li></ul></dd></dl> <p>The query result is the response structure: </p> <div class="mw-highlight mw-content-ltr" dir="ltr"><pre><span class="nt"><req</span> <span class="na">Host=</span><span class="s">"host"</span> <span class="na">URI=</span><span class="s">"uri"</span> <span class="na">err=</span><span class="s">"err"</span> <span class="na">Protocol=</span><span class="s">"prt"</span> <span class="na">RezCod=</span><span class="s">"rCod"</span> <span class="na">RezStr=</span><span class="s">"rStr"</span><span class="nt">></span> <span class="nt"><prm</span> <span class="na">id=</span><span class="s">"pId"</span><span class="nt">></span>pVal<span class="nt"></prm></span> respVal <span class="nt"></req></span> </pre></div> <dl><dd>Where: <ul><li> <i>req</i> — request method.</li> <li> <i>host</i> — http-server address.</li> <li> <i>uri</i> — resource address.</li> <li> <i>err</i> — error occurring during the request. In the case of a successful request, this field is empty.</li> <li> <i>RezCod</i>, <i>RezStr</i> — query result in the form of code and text.</li> <li> <i>pId</i>, <i>pVal</i> — identifier and value of the addition http-parameter. Http-parameters can be many, defined by the individual <i>prm</i> tags.</li> <li> <i>respVal</i> — content of the response.</li></ul></dd></dl> <p>Here is the formation of GET and POST requests in the JavaLikeCalc.JavaScript language, as an example of using this function in user procedures: </p> <div class="mw-highlight mw-content-ltr" dir="ltr"><pre><span class="c1">//GET request for a HTML-page</span> <span class="nx">req</span> <span class="o">=</span> <span class="nx">SYS</span><span class="p">.</span><span class="nx">XMLNode</span><span class="p">(</span><span class="s2">"GET"</span><span class="p">);</span> <span class="nx">req</span><span class="p">.</span><span class="nx">setAttr</span><span class="p">(</span><span class="s2">"URI"</span><span class="p">,</span><span class="s2">"/"</span><span class="p">);</span> <span class="nx">SYS</span><span class="p">.</span><span class="nx">Transport</span><span class="p">.</span><span class="nx">Sockets</span><span class="p">.</span><span class="nx">out_testHTTP</span><span class="p">.</span><span class="nx">messIO</span><span class="p">(</span><span class="nx">req</span><span class="p">,</span><span class="s2">"HTTP"</span><span class="p">);</span> <span class="nx">test</span> <span class="o">=</span> <span class="nx">req</span><span class="p">.</span><span class="nx">text</span><span class="p">();</span> <span class="c1">//GET request and saving a file</span> <span class="nx">req</span> <span class="o">=</span> <span class="nx">SYS</span><span class="p">.</span><span class="nx">XMLNode</span><span class="p">(</span><span class="s2">"GET"</span><span class="p">);</span> <span class="nx">req</span><span class="p">.</span><span class="nx">setAttr</span><span class="p">(</span><span class="s2">"URI"</span><span class="p">,</span><span class="s2">"/oscadaArch/Work/openscada-0.9-r2188.tar.lzma"</span><span class="p">);</span> <span class="nx">SYS</span><span class="p">.</span><span class="nx">Transport</span><span class="p">.</span><span class="nx">Sockets</span><span class="p">.</span><span class="nx">out_testHTTP</span><span class="p">.</span><span class="nx">messIO</span><span class="p">(</span><span class="nx">req</span><span class="p">,</span><span class="s2">"HTTP"</span><span class="p">);</span> <span class="k">if</span><span class="p">(</span><span class="o">!</span><span class="nx">req</span><span class="p">.</span><span class="nx">attr</span><span class="p">(</span><span class="s2">"err"</span><span class="p">).</span><span class="nx">length</span><span class="p">)</span> <span class="nx">SYS</span><span class="p">.</span><span class="nx">fileWrite</span><span class="p">(</span><span class="s2">"/var/tmp/recvFile.tmp"</span><span class="p">,</span> <span class="nx">req</span><span class="p">.</span><span class="nx">text</span><span class="p">());</span> <span class="c1">//POST request</span> <span class="nx">req</span> <span class="o">=</span> <span class="nx">SYS</span><span class="p">.</span><span class="nx">XMLNode</span><span class="p">(</span><span class="s2">"POST"</span><span class="p">);</span> <span class="nx">req</span><span class="p">.</span><span class="nx">setAttr</span><span class="p">(</span><span class="s2">"URI"</span><span class="p">,</span><span class="s2">"/WebUser/FlowTec.txt"</span><span class="p">);</span> <span class="nx">cntNode</span> <span class="o">=</span> <span class="nx">req</span><span class="p">.</span><span class="nx">childAdd</span><span class="p">(</span><span class="s2">"cnt"</span><span class="p">).</span><span class="nx">setAttr</span><span class="p">(</span><span class="s2">"name"</span><span class="p">,</span><span class="s2">"pole0"</span><span class="p">).</span><span class="nx">setAttr</span><span class="p">(</span><span class="s2">"filename"</span><span class="p">,</span><span class="s2">"Object2-k001-100309-17.txt"</span><span class="p">);</span> <span class="nx">cntNode</span><span class="p">.</span><span class="nx">childAdd</span><span class="p">(</span><span class="s2">"prm"</span><span class="p">).</span><span class="nx">setAttr</span><span class="p">(</span><span class="s2">"id"</span><span class="p">,</span><span class="s2">"Content-Type"</span><span class="p">).</span><span class="nx">setText</span><span class="p">(</span><span class="s2">"text/plain"</span><span class="p">);</span> <span class="nx">cntText</span> <span class="o">=</span> <span class="s2">"Object2-k001\r\n"</span><span class="p">;</span> <span class="nx">cntText</span> <span class="o">+=</span> <span class="s2">"\r\n"</span><span class="p">;</span> <span class="nx">cntText</span> <span class="o">+=</span> <span class="s2">"v002\r\n"</span><span class="p">;</span> <span class="nx">cntText</span> <span class="o">+=</span> <span class="s2">" n1\r\n"</span><span class="p">;</span> <span class="nx">cntText</span> <span class="o">+=</span> <span class="s2">" 09.03.10 16 Polnyj 7155.25 216.0 32.000 17.5\r\n"</span><span class="p">;</span> <span class="nx">cntText</span> <span class="o">+=</span> <span class="s2">"v005\r\n"</span><span class="p">;</span> <span class="nx">cntText</span> <span class="o">+=</span> <span class="s2">" n1\r\n"</span><span class="p">;</span> <span class="nx">cntText</span> <span class="o">+=</span> <span class="s2">" 09.03.10 16 Polnyj 188.81 350.0 4.000 40.0\r\n"</span><span class="p">;</span> <span class="nx">cntText</span> <span class="o">+=</span> <span class="s2">"\r\n"</span><span class="p">;</span> <span class="nx">cntNode</span><span class="p">.</span><span class="nx">setText</span><span class="p">(</span><span class="nx">cntText</span><span class="p">);</span> <span class="nx">SYS</span><span class="p">.</span><span class="nx">Transport</span><span class="p">.</span><span class="nx">Sockets</span><span class="p">.</span><span class="nx">out_testHTTP</span><span class="p">.</span><span class="nx">messIO</span><span class="p">(</span><span class="nx">req</span><span class="p">,</span><span class="s2">"HTTP"</span><span class="p">);</span> <span class="c1">//POST request with single content</span> <span class="nx">req</span> <span class="o">=</span> <span class="nx">SYS</span><span class="p">.</span><span class="nx">XMLNode</span><span class="p">(</span><span class="s2">"POST"</span><span class="p">);</span> <span class="nx">req</span><span class="p">.</span><span class="nx">setAttr</span><span class="p">(</span><span class="s2">"URI"</span><span class="p">,</span><span class="s2">"/WebUser/FlowTec.txt"</span><span class="p">);</span> <span class="nx">req</span><span class="p">.</span><span class="nx">childAdd</span><span class="p">(</span><span class="s2">"prm"</span><span class="p">).</span><span class="nx">setAttr</span><span class="p">(</span><span class="s2">"id"</span><span class="p">,</span><span class="s2">"Content-Type"</span><span class="p">).</span><span class="nx">setText</span><span class="p">(</span><span class="s2">"text/plain"</span><span class="p">);</span> <span class="nx">cntText</span> <span class="o">=</span> <span class="s2">"Object2-k001\r\n"</span><span class="p">;</span> <span class="nx">cntText</span> <span class="o">+=</span> <span class="s2">"\r\n"</span><span class="p">;</span> <span class="nx">cntText</span> <span class="o">+=</span> <span class="s2">"v002\r\n"</span><span class="p">;</span> <span class="nx">cntText</span> <span class="o">+=</span> <span class="s2">" n1\r\n"</span><span class="p">;</span> <span class="nx">cntText</span> <span class="o">+=</span> <span class="s2">" 09.03.10 16 Polnyj 7155.25 216.0 32.000 17.5\r\n"</span><span class="p">;</span> <span class="nx">cntText</span> <span class="o">+=</span> <span class="s2">"v005\r\n"</span><span class="p">;</span> <span class="nx">cntText</span> <span class="o">+=</span> <span class="s2">" n1\r\n"</span><span class="p">;</span> <span class="nx">cntText</span> <span class="o">+=</span> <span class="s2">" 09.03.10 16 Polnyj 188.81 350.0 4.000 40.0\r\n"</span><span class="p">;</span> <span class="nx">cntText</span> <span class="o">+=</span> <span class="s2">"\r\n"</span><span class="p">;</span> <span class="nx">req</span><span class="p">.</span><span class="nx">setText</span><span class="p">(</span><span class="nx">cntText</span><span class="p">);</span> <span class="nx">SYS</span><span class="p">.</span><span class="nx">Transport</span><span class="p">.</span><span class="nx">Sockets</span><span class="p">.</span><span class="nx">out_testHTTP</span><span class="p">.</span><span class="nx">messIO</span><span class="p">(</span><span class="nx">req</span><span class="p">,</span><span class="s2">"HTTP"</span><span class="p">);</span> </pre></div> <h2><span class="mw-headline" id="User_programming_API"><span class="mw-headline-number">4</span> User programming API</span></h2> <p><b>Input part of the module object (SYS.Protocol.HTTP.{In})</b> </p> <ul><li> <i>bool setUser( string user )</i> — changes the user linked to the authentication session ID. <ul><li> <i>user</i> — user to change.</li></ul></li> <li> <i>bool pgAccess(string URL)</i> — checks for accessing the page, pointed by the <i>URL</i>. <ul><li> <i>URL</i> — URL of the checking page.</li></ul></li> <li> <i>string pgCreator(string cnt, string rcode = "", string httpattrs = "Content-Type: text/html;charset={SYS}", string htmlHeadEls = "", string forceTmplFile = "" )</i> — forms for a page or a resource from the content <i>cnt</i>, wrapped to HTTP with the result <i>rcode</i>, with HTTP additional attributes <i>httpattrs</i>, HTML additional head's element <i>htmlHeadEls</i>, forced to template file <i>forceTmplFile</i>. <ul><li> <i>cnt</i> — content of the page or the resource (images, XML, CSS, JavaScript, ...) ;</li> <li> <i>rcode</i> — HTTP result code, like to "200 OK"; empty value there disables addition of the HTTP header;</li> <li> <i>httpattrs</i> — additional HTTP-attributes, mostly this is "Content-Type" which by default sets to "text/html;charset={SYS}"; only for "Content-Type: text/html" will be wrapped to internal/service or force <i>forceTmplFile</i> HTML-template;</li> <li> <i>htmlHeadEls</i> — additional HTML-header's tag, it's mostly META with "Refresh" to the specified URL;</li> <li> <i>forceTmplFile</i> — force template file to override the internal/service or the main-page template.</li></ul></li></ul> </div><table style="border-top: dotted 2px #999999; margin-top: 20pt; color: gray;" width="100%"><tr><td style="text-align: left;" width="40%"><a href="http://oscada.org/wiki/Modules/HTTP/en">Modules/HTTP/en</a> - <a href="http://oscada.org/en/main/about-the-project/licenses/">GFDL</a></td><td style="text-align: center;">April 2025</td><td style="text-align: right;" width="40%">OpenSCADA 1+r3018</td></tr></table></body> </html>