diff --git a/http.c b/http.c index b8ae1aa..7bf682d 100644 --- a/http.c +++ b/http.c @@ -232,9 +232,9 @@ http_parse_header(const char *h, struct request *req) if (q - p + 1 > PATH_MAX) { return S_REQUEST_TOO_LARGE; } - memcpy(req->target, p, q - p); - req->target[q - p] = '\0'; - decode(req->target, req->target); + memcpy(req->uri, p, q - p); + req->uri[q - p] = '\0'; + decode(req->uri, req->uri); /* basis for next step */ p = q + 1; @@ -566,7 +566,7 @@ http_prepare_response(const struct request *req, struct response *res, memset(res, 0, sizeof(*res)); /* make a working copy of the URI and normalize it */ - memcpy(realuri, req->target, sizeof(realuri)); + memcpy(realuri, req->uri, sizeof(realuri)); if (normabspath(realuri)) { return S_BAD_REQUEST; } @@ -593,7 +593,7 @@ http_prepare_response(const struct request *req, struct response *res, } } - /* apply target prefix mapping */ + /* apply URI prefix mapping */ for (i = 0; i < s->map_len; i++) { len = strlen(s->map[i].from); if (!strncmp(realuri, s->map[i].from, len)) { @@ -604,7 +604,7 @@ http_prepare_response(const struct request *req, struct response *res, continue; } - /* swap out target prefix */ + /* swap out URI prefix */ memmove(realuri, realuri + len, strlen(realuri) + 1); if (prepend(realuri, LEN(realuri), s->map[i].to)) { return S_REQUEST_TOO_LARGE; @@ -636,7 +636,7 @@ http_prepare_response(const struct request *req, struct response *res, } /* - * reject hidden target, except if it is a well-known URI + * reject hidden targets, except if it is a well-known URI * according to RFC 8615 */ if (strstr(realuri, "/.") && strncmp(realuri, @@ -648,7 +648,7 @@ http_prepare_response(const struct request *req, struct response *res, * redirect if the original URI and the "real" URI differ or if * the requested host is non-canonical */ - if (strcmp(req->target, realuri) || (s->vhost && vhost && + if (strcmp(req->uri, realuri) || (s->vhost && vhost && strcmp(req->field[REQ_HOST], vhost->chost))) { res->status = S_MOVED_PERMANENTLY; @@ -700,11 +700,11 @@ http_prepare_response(const struct request *req, struct response *res, * (optionally including the vhost servedir as a prefix) * into the actual response-path */ - if (esnprintf(res->uri, sizeof(res->uri), "%s", req->target)) { + if (esnprintf(res->uri, sizeof(res->uri), "%s", req->uri)) { return S_REQUEST_TOO_LARGE; } if (esnprintf(res->path, sizeof(res->path), "%s%s", - vhost ? vhost->dir : "", RELPATH(req->target))) { + vhost ? vhost->dir : "", RELPATH(req->uri))) { return S_REQUEST_TOO_LARGE; } } @@ -715,7 +715,7 @@ http_prepare_response(const struct request *req, struct response *res, * the URI */ if (esnprintf(tmpuri, sizeof(tmpuri), "%s%s", - req->target, s->docindex)) { + req->uri, s->docindex)) { return S_REQUEST_TOO_LARGE; } diff --git a/http.h b/http.h index 2ee79af..a9cf871 100644 --- a/http.h +++ b/http.h @@ -28,7 +28,7 @@ extern const char *req_method_str[]; struct request { enum req_method method; - char target[PATH_MAX]; + char uri[PATH_MAX]; char field[NUM_REQ_FIELDS][FIELD_MAX]; }; diff --git a/main.c b/main.c index bb7233c..f292506 100644 --- a/main.c +++ b/main.c @@ -64,7 +64,7 @@ serve(int infd, const struct sockaddr_storage *in_sa, const struct server *s) goto cleanup; } printf("%s\t%s\t%d\t%s\t%s\n", tstmp, inaddr, status, - c.req.field[REQ_HOST], c.req.target); + c.req.field[REQ_HOST], c.req.uri); cleanup: /* clean up and finish */ shutdown(c.fd, SHUT_RD); diff --git a/quark.1 b/quark.1 index 7188df2..d1dcb3d 100644 --- a/quark.1 +++ b/quark.1 @@ -1,4 +1,4 @@ -.Dd 2020-08-18 +.Dd 2020-08-22 .Dt QUARK 1 .Os suckless.org .Sh NAME @@ -63,7 +63,7 @@ The default is "index.html". .It Fl l Enable directory listing. .It Fl m Ar map -Add the target prefix mapping rule specified by +Add the URI prefix mapping rule specified by .Ar map , which has the form .Qq Pa from to [chost] , @@ -72,7 +72,7 @@ escaped with '\\'. .Pp The prefix .Pa from -of all matching targets is replaced with +of all matching URIs is replaced with .Pa to , optionally limited to the canonical virtual host .Pa chost . @@ -117,7 +117,7 @@ is redirected to the canonical host .Pa chost , if they differ, using the directory .Pa dir -as the root directory, optionally prefixing the target with +as the root directory, optionally prefixing the URI with .Pa prefix . If any virtual hosts are specified, all requests on non-matching hosts are discarded.