]> matita.cs.unibo.it Git - helm.git/commitdiff
implemented hostname resolution for "addr" parameter
authorStefano Zacchiroli <zack@upsilon.cc>
Mon, 24 May 2004 12:46:57 +0000 (12:46 +0000)
committerStefano Zacchiroli <zack@upsilon.cc>
Mon, 24 May 2004 12:46:57 +0000 (12:46 +0000)
helm/DEVEL/ocaml-http/http_misc.ml

index 5b04f2c377389c6387848dfaaf4b95f6ee204d04..fcec70ca5f4016523fca8e8bf757aa4e4f045cee 100644 (file)
@@ -98,7 +98,9 @@ let reason_phrase_of_code = function
   | invalid_code -> raise (Invalid_code invalid_code)
 
 let build_sockaddr (addr, port) =
-  Unix.ADDR_INET (Unix.inet_addr_of_string addr, port)
+  try
+    Unix.ADDR_INET ((Unix.gethostbyname addr).Unix.h_addr_list.(0), port)
+  with Not_found -> failwith ("OCaml-HTTP, can't resolve hostname: " ^ addr)
 
 let explode_sockaddr = function
   | Unix.ADDR_INET (addr, port) -> (Unix.string_of_inet_addr addr, port)