mono/mono — pull request #891 by DavidKarlas (2014-02-08 13:10:45+00:00)
Title: HttpListener now listens on default ports if not specified instead of random

In method public static void CheckUri I just made code a bit nicer.

In method Parse I fixed bug where default_port variable was set but never used in case if URI did not have port specified. Since port was set by default 0 HttpListener would listen on random port instead 80 or 443. Also notice that this class is private and only used by Mono so CheckUri is always called before Parse() which means only "http://" and "https://" schemas are possible so I changed beginning of Parse method a bit. "optimization" :)

This is also behaviour of .Net(no port specified results in port 80 on http schema).

I ran into this problem using Nancy because there self hosting accepts Uri objects which is later sent to HttpListener prefixes by using .ToString() which omits port number(see Uri.cs).

Seems like some other guys ran into same problem here: http://stackoverflow.com/questions/19741880/nancy-mono-self-host-wont-start-on-port-80