Return proper error-status when http_send_header() fails
Explicitly show that we set the status of the response struct to the returned error status. This makes it clear that we are beyond the point where the "form" of the response struct matters and it's now only about the log-output. Signed-off-by: Laslo Hunhold <dev@frign.de>
This commit is contained in:
parent
c0909c70e4
commit
68e4ff3021
2 changed files with 10 additions and 8 deletions
2
http.c
2
http.c
|
@ -110,7 +110,7 @@ http_send_header(int fd, const struct response *res)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return res->status;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
6
main.c
6
main.c
|
@ -45,14 +45,16 @@ serve(int infd, const struct sockaddr_storage *in_sa, const struct server *srv)
|
||||||
http_prepare_response(&c.req, &c.res, srv);
|
http_prepare_response(&c.req, &c.res, srv);
|
||||||
}
|
}
|
||||||
|
|
||||||
status = http_send_header(c.fd, &c.res);
|
if ((status = http_send_header(c.fd, &c.res))) {
|
||||||
|
c.res.status = status;
|
||||||
|
} else {
|
||||||
/* send data */
|
/* send data */
|
||||||
if (c.res.type == RESTYPE_FILE) {
|
if (c.res.type == RESTYPE_FILE) {
|
||||||
resp_file(c.fd, &c.res);
|
resp_file(c.fd, &c.res);
|
||||||
} else if (c.res.type == RESTYPE_DIRLISTING) {
|
} else if (c.res.type == RESTYPE_DIRLISTING) {
|
||||||
resp_dir(c.fd, &c.res);
|
resp_dir(c.fd, &c.res);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* write output to log */
|
/* write output to log */
|
||||||
t = time(NULL);
|
t = time(NULL);
|
||||||
|
|
Loading…
Reference in a new issue