Implemented HTTPS server support.
Use new function of httputils.
Remved duplicated code.