+ /*
+ * 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(block(plex, EV_WRITE, 60) <= 0)
+ goto out;
+ if(socketpair(PF_UNIX, SOCK_STREAM, 0, pfds))