<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.ice-online.com/index.php?action=history&amp;feed=atom&amp;title=HTTPSERV</id>
	<title>HTTPSERV - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.ice-online.com/index.php?action=history&amp;feed=atom&amp;title=HTTPSERV"/>
	<link rel="alternate" type="text/html" href="https://wiki.ice-online.com/index.php?title=HTTPSERV&amp;action=history"/>
	<updated>2026-08-04T00:53:05Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.1</generator>
	<entry>
		<id>https://wiki.ice-online.com/index.php?title=HTTPSERV&amp;diff=856&amp;oldid=prev</id>
		<title>ConvertBot: An HTTP/1.1 server to serve files rooted in given directory.</title>
		<link rel="alternate" type="text/html" href="https://wiki.ice-online.com/index.php?title=HTTPSERV&amp;diff=856&amp;oldid=prev"/>
		<updated>2020-04-27T22:05:18Z</updated>

		<summary type="html">&lt;p&gt;An HTTP/1.1 server to serve files rooted in given directory.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;An HTTP/1.1 server to serve files rooted in given directory.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;PORT&amp;gt; The port that the web server is to run on. [default=8080]&lt;br /&gt;
       Use 0 for any free port (Since NeXtMidas 2.7.0, once server is running,&lt;br /&gt;
       port is updated and printed to reflect the actual listen port.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;DIR&amp;gt;  The directory containing the files to be served.  If the parameter&lt;br /&gt;
       begins with a slash (/) then it is assumed to be an absolute pathname,&lt;br /&gt;
       otherwise it is assumed to be relative to NMROOT.  [default=htmlhelp]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;NAME&amp;gt; The alias by which the directory will be accessed. [default=dat]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The NAME parameter is the alias used by the web server for the directory.&lt;br /&gt;
HTTP requests that begin with the specified name will be mapped to a file&lt;br /&gt;
that is contained in the given directory.  Files in subdirectories will be&lt;br /&gt;
served if the request URI begins with the NAME.&lt;br /&gt;
&lt;br /&gt;
    +---------------------------------------------------------------+&lt;br /&gt;
    |                           WARNING                             |&lt;br /&gt;
    | Unlike most web servers, the names of the file accessible via |&lt;br /&gt;
    | HTTPSERV should be assumed to be case sensitive.              |&lt;br /&gt;
    +---------------------------------------------------------------+&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Messages:&lt;br /&gt;
  HTTPGET    - Send from primitive to /MSGID= with the following:&lt;br /&gt;
                  NAME=HTTPGET&lt;br /&gt;
                  INFO=0&lt;br /&gt;
                  DATA={SOCKET=&amp;lt;outputSock&amp;gt;,PARAMAMETERS=&amp;lt;params&amp;gt;}&lt;br /&gt;
               &amp;lt;outputSock&amp;gt; is an instance of nxm.sys.net.HPage&lt;br /&gt;
               &amp;lt;params&amp;gt;     is a Table of input parameters (same as calling&lt;br /&gt;
                            &amp;lt;outputSock&amp;gt;.getParameters())&lt;br /&gt;
&lt;br /&gt;
               Note that the macro ***MUST*** invoke both openSocket() and&lt;br /&gt;
               closeSocket() on the &amp;lt;outputSock&amp;gt;. Failure to do this will cause&lt;br /&gt;
               the request handler to hang!!!&lt;br /&gt;
&lt;br /&gt;
  HTTPPOST   - Same as HTTPGET, except for an HTTP POST request. See the API&lt;br /&gt;
               for HPage.getPostData() for details on accessing POST data.&lt;br /&gt;
               (Note: Support for HTTP POST was added in NeXtMidas 2.7.0)&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
  1. Make the files in &amp;quot;${NMROOT}/nxm/sys/dat&amp;quot; available on the net via&lt;br /&gt;
     &amp;quot;http://hostname:8080/dat/&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
       nM&amp;gt; httpserv 8080 DIR=&amp;quot;nxm/sys/dat&amp;quot; NAME=&amp;quot;dat&amp;quot;&lt;br /&gt;
&lt;br /&gt;
     This will instantiate a server on port 8080 that will serve files rooted&lt;br /&gt;
     in the ${NMROOT}/nxm/sys/dat directory and will use 'dat' as the alias for&lt;br /&gt;
     this directory.&lt;br /&gt;
&lt;br /&gt;
     While this is running, you can do the following from another system:&lt;br /&gt;
       nM&amp;gt; status http://hostname:8080/dat/apenny.prm&lt;br /&gt;
&lt;br /&gt;
     or even&lt;br /&gt;
       nM&amp;gt; noop http://hostname:8080/dat/apenny.prm localpenny&lt;br /&gt;
&lt;br /&gt;
     This connection is not limited to NeXtMidas sessions, any program with&lt;br /&gt;
     HTTP access can access the files, for example a web browser can load the&lt;br /&gt;
     &amp;quot;Sunset.jpg&amp;quot; file using &amp;quot;http://hostname:8080/dat/Sunset.jpg&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
     Note that by default ALL files under $NMROOT are accessible via&lt;br /&gt;
     &amp;quot;http://hostname:8080/nmroot/&amp;quot; also note that any web browser pointed&lt;br /&gt;
     to &amp;quot;http://hostname:8080/&amp;quot; will automatically be able to access the&lt;br /&gt;
     NeXtMidas documentation (if built) and status information about any of&lt;br /&gt;
     the primitives running over the network.&lt;br /&gt;
&lt;br /&gt;
  2. Run SD360;SYS with HTTPSERV:&lt;br /&gt;
       nM&amp;gt; sd360/server=9000/http&lt;br /&gt;
&lt;br /&gt;
     Now it is possible to point a web browser to &amp;quot;http://hostname:9000/&amp;quot; and&lt;br /&gt;
     get status information about the running RMIF connection.&lt;br /&gt;
&lt;br /&gt;
     See the SD360 explain file for details.&lt;br /&gt;
&lt;br /&gt;
  3. Run HTTP server on any available port and display host and listen port&lt;br /&gt;
&lt;br /&gt;
       nM&amp;gt; httpserv port=0 /bg&lt;br /&gt;
       INFO: Starting HTTP Web Server at URL=http://&amp;lt;host&amp;gt;:&amp;lt;port&amp;gt;/ [HTTPSERV]&lt;br /&gt;
&lt;br /&gt;
       nM&amp;gt; say &amp;quot;using host=^{reg.httpserv.host} port=^{reg.httpserv.port}&amp;quot;&lt;br /&gt;
       using host=10.10.1.59 port=38375&lt;br /&gt;
&lt;br /&gt;
  4. Use the /MNAME= and /MSGID= switches to allow the macro to respond to a&lt;br /&gt;
     HTTP request:&lt;br /&gt;
        startmacro&lt;br /&gt;
          pipe on&lt;br /&gt;
            httpserv/msgid=main/mname=&amp;quot;mymacro&amp;quot; port=9999&lt;br /&gt;
          pipe off&lt;br /&gt;
        endmacro&lt;br /&gt;
&lt;br /&gt;
        procedure processMessage m:msg&lt;br /&gt;
          say &amp;quot;Got message name=^msg.name info=^msg.info data=^msg.data&amp;quot;&lt;br /&gt;
&lt;br /&gt;
          if msg.name eqs &amp;quot;HTTPGET&amp;quot; then&lt;br /&gt;
            set socket msg.data.socket&lt;br /&gt;
            set params msg.data.parameters&lt;br /&gt;
&lt;br /&gt;
            ! say &amp;quot;Got HTTPGET request, URI= ^{socket.uri}&amp;quot;&lt;br /&gt;
            invoke,,socket.openSocket()&lt;br /&gt;
            invoke,,socket.writeln(&amp;quot;Got request with ^{params}&amp;quot;)&lt;br /&gt;
            invoke,,socket.closeSocket()&lt;br /&gt;
          elseif msg.name eqs &amp;quot;HTTPPOST&amp;quot; then&lt;br /&gt;
            ...&lt;br /&gt;
          endif&lt;br /&gt;
        return&lt;br /&gt;
&lt;br /&gt;
     A client can then use &amp;quot;http://localhost:9999/mymacro?a=1&amp;amp;b=2&amp;amp;c=3&amp;quot; to access&lt;br /&gt;
     this macro. NOTE: The macro MUST invoke both openSocket() and closeSocket()&lt;br /&gt;
     on the &amp;lt;socket&amp;gt;. Failure to do this will cause the primitive to hang!!!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Switches:&lt;br /&gt;
  /AUXLIST=&amp;lt;l&amp;gt;  - List of AUXs to make available under&lt;br /&gt;
                  &amp;quot;http://host:port/Files/&amp;lt;AUX&amp;gt;/&amp;lt;filename&amp;gt;&amp;quot;. By default none&lt;br /&gt;
                  are listed (same as /AUXLIST=null). /AUXLIST=&amp;quot;*&amp;quot; serves up&lt;br /&gt;
                  everything in AUX.READ (use of /AUXLIST=&amp;quot;*&amp;quot; is very common).&lt;br /&gt;
  /HOMEPAGE=&amp;lt;p&amp;gt; - Homepage location for HTTP web server (&amp;lt;p&amp;gt; = path).&lt;br /&gt;
  /MNAME=&amp;lt;n&amp;gt;    - Turns on macro handling of requests where &amp;lt;n&amp;gt; is the name of&lt;br /&gt;
                  the macro as given in the HTTP request. If /MNAME=&amp;quot;/mymacro&amp;quot;&lt;br /&gt;
                  (or /MNAME=&amp;quot;mymacro&amp;quot;, leading slash is implied) then the&lt;br /&gt;
                  client uses &amp;quot;http://&amp;lt;server&amp;gt;:&amp;lt;port&amp;gt;/mymacro&amp;quot; to access it).&lt;br /&gt;
                  When this is enabled HTTPGET and/or HTTPPOST messages will&lt;br /&gt;
                  be sent to /MSGID=. If /MNAME=&amp;quot;/&amp;quot; (e.g. root alias) then all&lt;br /&gt;
                  requests will be forwarded specified message handler otherwise&lt;br /&gt;
                  the default HServer index will serve up the / requests.&lt;br /&gt;
  /MSGID=&amp;lt;n&amp;gt;    - Registry name of command to handle messages (usually MAIN),&lt;br /&gt;
                  only used with /MNAME= switch.&lt;br /&gt;
  /PRANGE=n     - Range of port numbers above &amp;lt;PORT&amp;gt; to use if already&lt;br /&gt;
                  allocated. [DEF=1] Since 2.9.3.&lt;br /&gt;
&lt;br /&gt;
See Also: RMIF, nxm.sys.net.HServer, nxm.sys.net.HPage&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:NXM_Explain]]&lt;/div&gt;</summary>
		<author><name>ConvertBot</name></author>
		
	</entry>
</feed>