From 771e649c41ebb75fe5d3889ef030dc7f9cf28209 Mon Sep 17 00:00:00 2001
From: Richard Nyberg <rnyberg@murmeldjur.se>
Date: Sat, 19 May 2007 13:06:37 +0000
Subject: [PATCH] Don't try to resolve the host if it is already given as an ip
 address.

---
 misc/http_client.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/misc/http_client.c b/misc/http_client.c
index e6a2ed6..13f5c28 100644
--- a/misc/http_client.c
+++ b/misc/http_client.c
@@ -416,6 +416,7 @@ int
 http_get(struct http_req **out, const char *url, const char *hdrs,
     http_cb_t cb, void *arg)
 {
+    struct in_addr addr;
     struct http_req *req = calloc(1, sizeof(*req));
     if (req == NULL)
         return 0;
@@ -434,7 +435,9 @@ http_get(struct http_req **out, const char *url, const char *hdrs,
             "%s"
             "\r\n", req->url->uri, req->url->host, hdrs) == -1)
         goto error;
-    if (evdns_resolve_ipv4(req->url->host, 0, http_dnscb, req) != 0)
+    if (inet_aton(req->url->host, &addr) == 1)
+        http_dnscb(DNS_ERR_NONE, DNS_IPv4_A, 1, 0, &addr, req);
+    else if (evdns_resolve_ipv4(req->url->host, 0, http_dnscb, req) != 0)
         goto error;
     if (out != NULL)
         *out = req;