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