http_lib.c - rewrite somewhat to meet our requirements