- /*
- * 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);
-
- /*
- * 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)));
- }
- cfd = sendreq(plex, req);
+ if((req = parsereq(in)) == NULL)
+ break;
+ replrest(req, req->url);
+ if(req->rest[0] == '/')
+ replrest(req, req->rest + 1);
+ if((p = strchr(req->rest, '?')) != NULL)
+ *p = 0;