[hackers] [quark] Rename "target" to "URI" where appropriate || Laslo Hunhold
commit 50c85ec642d1327135eb5a58c6d1ffc1ee0d41dc
Author: Laslo Hunhold <dev_AT_frign.de>
AuthorDate: Sat Aug 22 23:37:08 2020 +0200
Commit: Laslo Hunhold <dev_AT_frign.de>
CommitDate: Sat Aug 22 23:38:38 2020 +0200
Rename "target" to "URI" where appropriate
Of course URIs point at "targets", but the URIs themselves should
be called what they are, not only in the interest of clarity in terms
of nomenclature.
Signed-off-by: Laslo Hunhold <dev_AT_frign.de>
diff --git a/http.c b/http.c
index b8ae1aa..7bf682d 100644
--- a/http.c
+++ b/http.c
_AT_@ -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;
_AT_@ -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;
}
_AT_@ -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)) {
_AT_@ -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;
_AT_@ -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,
_AT_@ -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;
_AT_@ -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;
}
}
_AT_@ -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
_AT_@ -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
_AT_@ -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
_AT_@ -1,4 +1,4 @@
-.Dd 2020-08-18
+.Dd 2020-08-22
.Dt QUARK 1
.Os suckless.org
.Sh NAME
_AT_@ -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] ,
_AT_@ -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 .
_AT_@ -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.
Received on Sat Aug 22 2020 - 23:38:14 CEST
This archive was generated by hypermail 2.3.0
: Sat Aug 22 2020 - 23:48:34 CEST