+ /*
+ * First, find and decode the header:
+ */
+ if((headoff = readhead(fd, &inbuf)) < 0)
+ goto out;
+ if(headoff > 65536) {
+ /* We cannot handle arbitrarily large headers, as they
+ * need to fit within a single Unix datagram. This is
+ * probably a safe limit, and larger packets than this are
+ * most likely erroneous (or malicious) anyway. */
+ goto out;
+ }
+ old = inbuf.b[headoff];
+ inbuf.b[headoff] = 0;
+ if((req = parserawreq(inbuf.b)) == NULL)
+ goto out;
+ inbuf.b[headoff] = old;
+ bufeat(inbuf, headoff);
+ /* We strip off the leading slash and any param string from
+ * the rest string, so that multiplexers can parse
+ * coherently. */
+ if(req->rest[0] == '/')
+ replrest(req, req->rest + 1);
+ if((p = strchr(req->rest, '?')) != NULL)
+ *p = 0;
+
+ /*
+ * Add metainformation and then send the request to the root
+ * multiplexer:
+ */
+ if(name.ss_family == AF_INET) {
+ headappheader(req, "X-Ash-Address", inet_ntop(AF_INET, &((struct sockaddr_in *)&name)->sin_addr, nmbuf, sizeof(nmbuf)));
+ headappheader(req, "X-Ash-Port", sprintf3("%i", ntohs(((struct sockaddr_in *)&name)->sin_port)));
+ } else if(name.ss_family == AF_INET6) {
+ headappheader(req, "X-Ash-Address", inet_ntop(AF_INET6, &((struct sockaddr_in6 *)&name)->sin6_addr, nmbuf, sizeof(nmbuf)));
+ headappheader(req, "X-Ash-Port", sprintf3("%i", ntohs(((struct sockaddr_in6 *)&name)->sin6_port)));
+ }
+ if((cfd = sendreq(plex, req)) < 0)
+ goto out;
+
+ /*
+ * If there is message data, pass it:
+ */
+ if((hd = getheader(req, "content-length")) != NULL) {
+ dlen = atoo(hd);
+ if(dlen > 0)
+ passdata(fd, cfd, &inbuf, dlen);
+ }
+ /* Make sure to send EOF */
+ shutdown(cfd, SHUT_WR);
+
+ /*
+ * Find and decode the response header:
+ */
+ outbuf.d = 0;
+ if((headoff = readhead(cfd, &outbuf)) < 0)