/*
* Look for the given header in headers.
* If value is specified look for it terminated with a character in eov.
+ * If fvalue is specified and the header was found, then *fvalue will point to
+ * the found header's value.
*/
static bool
have_header(isc_httpd_t *httpd, const char *header, const char *value,
- const char *eov) {
+ const char *eov, const char **fvalue) {
char *cr, *nl, *h;
size_t hlen, vlen = 0;
continue;
}
- if (value == NULL) {
- return (true);
- }
-
/*
* Skip optional leading white space.
*/
while (*h == ' ' || *h == '\t') {
h++;
}
+
+ /*
+ * Set the found value.
+ */
+ if (fvalue != NULL) {
+ *fvalue = h;
+ }
+
+ if (value == NULL) {
+ return (true);
+ }
+
/*
* Terminate token search on NULL or EOL.
*/
httpd->headers = s;
- if (have_header(httpd, "Connection:", "close", ", \t\r\n")) {
+ if (have_header(httpd, "Connection:", "close", ", \t\r\n", NULL)) {
httpd->flags |= HTTPD_CLOSE;
}
- if (have_header(httpd, "Host:", NULL, NULL)) {
+ if (have_header(httpd, "Host:", NULL, NULL, NULL)) {
httpd->flags |= HTTPD_FOUNDHOST;
}
if (strncmp(httpd->protocol, "HTTP/1.0", 8) == 0) {
- if (have_header(httpd, "Connection:", "Keep-Alive", ", \t\r\n"))
- {
+ if (have_header(httpd, "Connection:", "Keep-Alive", ", \t\r\n",
+ NULL)) {
httpd->flags |= HTTPD_KEEPALIVE;
} else {
httpd->flags |= HTTPD_CLOSE;
* Check for Accept-Encoding:
*/
#ifdef HAVE_ZLIB
- if (have_header(httpd, "Accept-Encoding:", "deflate", ";, \t\r\n")) {
+ if (have_header(httpd, "Accept-Encoding:", "deflate", ";, \t\r\n",
+ NULL)) {
httpd->flags |= HTTPD_ACCEPT_DEFLATE;
}
#endif /* ifdef HAVE_ZLIB */