Client IP address in MiServer 3

MiServer is Dyalog's APL-based web development framework

Client IP address in MiServer 3

Postby ray on Sat Oct 25, 2014 1:08 pm

Hi,

I have a MiServer 3 web page.

Within the Render function, how can I find out the IP address of the browser reading my page?

Thanks

Ray
Ray Cannon
Please excuse any smelling pisstakes.
User avatar
ray
 
Posts: 238
Joined: Wed Feb 24, 2010 12:24 am
Location: Blackwater, Camberley. UK

Re: Client IP address in MiServer 3

Postby Morten|Dyalog on Sun Oct 26, 2014 7:56 am

Note that the specification of MS3 is still subject to change until we make the first official release.

The "request" object that is received as the right argument to the Render function in MiServer 2 is available as a global name under MS3, named _Request. In both versions, this is an object which contains a wealth of information about the request:

      _Request.⎕nl -2
Arguments Bytes Command Cookies Data Filename Headers Input MSec
Page PeerAddr PeerCert Response RestReq Server Session

_Request.Headers ⍝ For example this property contains the request headers
host localhost:8080
connection keep-alive
cache-control max-age=0
accept text/html,application/xhtml+xml,application/xml...
user-agent Mozilla/5.0 (Windows NT 6.3; WOW64) ...
accept-encoding gzip, deflate...

The "PeerAddr" property is a 4-element vector containing the IP protocol, a character representation of the address and port number, a numeric vector containing the address (note this will be longer for IPv6) and finally the numeric port number:

      request.PeerAddr
IPv4 127.0.0.1:51428 127 0 0 1 51428
User avatar
Morten|Dyalog
 
Posts: 460
Joined: Tue Sep 09, 2008 3:52 pm


Return to MiServer

Who is online

Users browsing this forum: No registered users and 1 guest