diff --git a/docs/c-api/dns.h/items.json b/docs/c-api/dns.h/items.json
index aa3452e7bcd33bb81e4ba94fec8810afc1717b52..8d21dd80d4dc6da649fab4db3400f4e9fbed2156 100644
--- a/docs/c-api/dns.h/items.json
+++ b/docs/c-api/dns.h/items.json
@@ -18,7 +18,7 @@
         },
         {
             "type": "markdown",
-            "name": "mg_dns_copy_body.md"
+            "name": "mg_dns_copy_questions.md"
         },
         {
             "type": "markdown",
diff --git a/docs/c-api/dns.h/mg_dns_copy_body.md b/docs/c-api/dns.h/mg_dns_copy_body.md
deleted file mode 100644
index b2ff61e6e67bf630a78dfe4182ecc4979478af57..0000000000000000000000000000000000000000
--- a/docs/c-api/dns.h/mg_dns_copy_body.md
+++ /dev/null
@@ -1,15 +0,0 @@
----
-title: "mg_dns_copy_body()"
-decl_name: "mg_dns_copy_body"
-symbol_kind: "func"
-signature: |
-  int mg_dns_copy_body(struct mbuf *io, struct mg_dns_message *msg);
----
-
-Append already encoded body from an existing message.
-
-This is useful when generating a DNS reply message which includes
-all question records.
-
-Return number of appened bytes. 
-
diff --git a/docs/c-api/dns.h/mg_dns_copy_questions.md b/docs/c-api/dns.h/mg_dns_copy_questions.md
new file mode 100644
index 0000000000000000000000000000000000000000..9fc2091fb0309be857a3516c11fb974644fc448c
--- /dev/null
+++ b/docs/c-api/dns.h/mg_dns_copy_questions.md
@@ -0,0 +1,15 @@
+---
+title: "mg_dns_copy_questions()"
+decl_name: "mg_dns_copy_questions"
+symbol_kind: "func"
+signature: |
+  int mg_dns_copy_questions(struct mbuf *io, struct mg_dns_message *msg);
+---
+
+Append already encoded questions from an existing message.
+
+This is useful when generating a DNS reply message which includes
+all question records.
+
+Return number of appened bytes. 
+
diff --git a/examples/captive_dns_server/captive_dns_server.c b/examples/captive_dns_server/captive_dns_server.c
index ac5781c28e845673cb4b9c7b4afef5e448f0eb92..0f1704354348ba4f76e361c03bbc54eee57aa071 100644
--- a/examples/captive_dns_server/captive_dns_server.c
+++ b/examples/captive_dns_server/captive_dns_server.c
@@ -23,28 +23,35 @@ static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
   int i;
 
   switch (ev) {
-    case MG_DNS_MESSAGE:
+    case MG_DNS_MESSAGE: {
+      struct mbuf reply_buf;
+      mbuf_init(&reply_buf, 512);
       msg = (struct mg_dns_message *) ev_data;
-      reply = mg_dns_create_reply(&nc->send_mbuf, msg);
+      reply = mg_dns_create_reply(&reply_buf, msg);
 
       for (i = 0; i < msg->num_questions; i++) {
+        char rname[256];
         rr = &msg->questions[i];
+        mg_dns_uncompress_name(msg, &rr->name, rname, sizeof(rname) - 1);
+        LOG(LL_INFO, ("Q type %d name %s", rr->rtype, rname));
         if (rr->rtype == MG_DNS_A_RECORD) {
-          mg_dns_reply_record(&reply, rr, NULL, rr->rtype, 3600,
-                              &s_our_ip_addr, 4);
+          mg_dns_reply_record(&reply, rr, NULL, rr->rtype, 10, &s_our_ip_addr,
+                              4);
         }
       }
 
       /*
        * We don't set the error flag even if there were no answers
-       * maching the MG_DNS_A_RECORD query type.
-       * This indicates that we have (syntetic) answers for MG_DNS_A_RECORD.
+       * matching the MG_DNS_A_RECORD query type.
+       * This indicates that we have (synthetic) answers for MG_DNS_A_RECORD.
        * See http://goo.gl/QWvufr for a distinction between NXDOMAIN and NODATA.
        */
 
       mg_dns_send_reply(nc, &reply);
       nc->flags |= MG_F_SEND_AND_CLOSE;
+      mbuf_free(&reply_buf);
       break;
+    }
   }
 }
 
@@ -55,6 +62,7 @@ int main(int argc, char *argv[]) {
 
   mg_mgr_init(&mgr, NULL);
   s_our_ip_addr = inet_addr("127.0.0.1");
+  cs_log_set_level(LL_INFO);
 
   /* Parse command line arguments */
   for (i = 1; i < argc; i++) {
diff --git a/mongoose.c b/mongoose.c
index b33b42c56331c5a14e6db43c949158ae1f010714..859c30ff09091e4853d3bffda6454621b9cdbe95 100644
--- a/mongoose.c
+++ b/mongoose.c
@@ -8841,9 +8841,14 @@ int mg_dns_insert_header(struct mbuf *io, size_t pos,
   return mbuf_insert(io, pos, &header, sizeof(header));
 }
 
-int mg_dns_copy_body(struct mbuf *io, struct mg_dns_message *msg) {
-  return mbuf_append(io, msg->pkt.p + sizeof(struct mg_dns_header),
-                     msg->pkt.len - sizeof(struct mg_dns_header));
+int mg_dns_copy_questions(struct mbuf *io, struct mg_dns_message *msg) {
+  unsigned char *begin, *end;
+  struct mg_dns_resource_record *last_q;
+  if (msg->num_questions <= 0) return 0;
+  begin = (unsigned char *) msg->pkt.p + sizeof(struct mg_dns_header);
+  last_q = &msg->questions[msg->num_questions - 1];
+  end = (unsigned char *) last_q->name.p + last_q->name.len + 4;
+  return mbuf_append(io, begin, end - begin);
 }
 
 static int mg_dns_encode_name(struct mbuf *io, const char *name, size_t len) {
@@ -9150,7 +9155,7 @@ struct mg_dns_reply mg_dns_create_reply(struct mbuf *io,
 
   /* reply + recursion allowed */
   msg->flags |= 0x8080;
-  mg_dns_copy_body(io, msg);
+  mg_dns_copy_questions(io, msg);
 
   msg->num_answers = 0;
   return rep;
diff --git a/mongoose.h b/mongoose.h
index 9626e4d8dfd55c8a0e7c04a743fbc9f19264007d..4063847d1ababdb9511d940fb88e6b3b638a9b9d 100644
--- a/mongoose.h
+++ b/mongoose.h
@@ -3253,14 +3253,14 @@ int mg_dns_insert_header(struct mbuf *io, size_t pos,
                          struct mg_dns_message *msg);
 
 /*
- * Append already encoded body from an existing message.
+ * Append already encoded questions from an existing message.
  *
  * This is useful when generating a DNS reply message which includes
  * all question records.
  *
  * Return number of appened bytes.
  */
-int mg_dns_copy_body(struct mbuf *io, struct mg_dns_message *msg);
+int mg_dns_copy_questions(struct mbuf *io, struct mg_dns_message *msg);
 
 /*
  * Encode and append a DNS resource record to an IO buffer.