Client IP address in MiServer 3

MiServer is Dyalog's APL-based web development framework
Post Reply
User avatar
ray
Posts: 238
Joined: Wed Feb 24, 2010 12:24 am
Location: Blackwater, Camberley. UK

Client IP address in MiServer 3

Post by ray »

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
Morten|Dyalog
Posts: 460
Joined: Tue Sep 09, 2008 3:52 pm

Re: Client IP address in MiServer 3

Post by Morten|Dyalog »

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
Post Reply