[Mono-dev] HttpListener

Greg Young gregoryyoung1 at gmail.com
Fri Apr 24 16:41:06 UTC 2015


Here is some of the code in question:

IPAddress addr;
if (host == "*")
    addr = IPAddress.Any;
else if (IPAddress.TryParse(host, out addr) == false){
    try {
        IPHostEntry iphost = Dns.GetHostByName(host);
       if (iphost != null)
            addr = iphost.AddressList[0];
       else
            addr = IPAddress.Any;
   } catch {
        addr = IPAddress.Any;
   }
}

On Fri, Apr 24, 2015 at 7:29 PM, Greg Young <gregoryyoung1 at gmail.com> wrote:
> I have been going through a bunch of this code lately after seeing
> many ... interesting behaviours. I understand that much of the derp in
> this code is due to not having IIS and MS having an IIS centric API
> but wow. Some gems I have found...
>
> 1) synchronous dns calls being made...
> 2) I want to listen on 192.168.0.1:1234 but I want to support a host
> header of whateverdomain can't resolve whatever domain then bind
> listeners to all ips on machine.
> 3) Same as above but dns entry has multiple ips it resovles to [0]
> doesnt match see #2
> 4) Anything at all to do with elastic ips
> 5) Exceptions thrown to calling code with http status codes in them (I
> think this is ms legacy but is a pretty biog wtf)
> 6) failure parsing ip address says bind all interfaces on machine (huh?)
>
> Perhaps it makes sense to expose a "Microsoft Http Compatibility
> Layer" and then have a "Sane API if you want to use it"
>
> I dont mind putting some time in on these but is this even worthwhile
> or is the plan to just burn this code with fire and move to something
> sane in general?
>
> Cheers,
>
> Greg
> --
> Studying for the Turing test



-- 
Studying for the Turing test


More information about the Mono-devel-list mailing list