Rename "target" to "URI" where appropriate - quark - quark web server | |
git clone git://git.suckless.org/quark | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit 50c85ec642d1327135eb5a58c6d1ffc1ee0d41dc | |
parent 68be64e2c12f6ab5355a147484896eae12d2b166 | |
Author: Laslo Hunhold <[email protected]> | |
Date: Sat, 22 Aug 2020 23:37:08 +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 <[email protected]> | |
Diffstat: | |
M http.c | 22 +++++++++++----------- | |
M http.h | 2 +- | |
M main.c | 2 +- | |
M quark.1 | 8 ++++---- | |
4 files changed, 17 insertions(+), 17 deletions(-) | |
--- | |
diff --git 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 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 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 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 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 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 r… | |
* (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 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 | |
@@ -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 | |
@@ -64,7 +64,7 @@ serve(int infd, const struct sockaddr_storage *in_sa, const 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 | |
@@ -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. |