mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 22:15:20 +00:00
Ignore an "Accept" HTTP header value
We were too strict regarding the value and presence of "Accept" HTTP header, slightly breaking compatibility with the specification. According to RFC8484 client SHOULD add "Accept" header to the requests but MUST be able to handle "application/dns-message" media type regardless of the value of the header. That basically suggests we ignore its value. Besides, verifying the value of the "Accept" header is a bit tricky because it could contain multiple media types, thus requiring proper parsing. That is doable but does not provide us with any benefits. Among other things, not verifying the value also fixes compatibility with clients, which could advertise multiple media types as supported, which we should accept. For example, it is possible for a perfectly valid request to contain "application/dns-message", "application/*", and "*/*" in the "Accept" header value. Still, we would treat such a request as invalid.
This commit is contained in:
@@ -1805,23 +1805,6 @@ server_handle_content_type_header(isc_nmsocket_t *socket, const uint8_t *value,
|
||||
return (resp);
|
||||
}
|
||||
|
||||
static isc_http_error_responses_t
|
||||
server_handle_accept_header(isc_nmsocket_t *socket, const uint8_t *value,
|
||||
const size_t valuelen) {
|
||||
const char type_accept_all[] = "*/*";
|
||||
const char type_dns_message[] = DNS_MEDIA_TYPE;
|
||||
isc_http_error_responses_t resp = ISC_HTTP_ERROR_SUCCESS;
|
||||
|
||||
UNUSED(socket);
|
||||
|
||||
if (!(HEADER_MATCH(type_dns_message, value, valuelen) ||
|
||||
HEADER_MATCH(type_accept_all, value, valuelen)))
|
||||
{
|
||||
resp = ISC_HTTP_ERROR_UNSUPPORTED_MEDIA_TYPE;
|
||||
}
|
||||
return (resp);
|
||||
}
|
||||
|
||||
static isc_http_error_responses_t
|
||||
server_handle_header(isc_nmsocket_t *socket, const uint8_t *name,
|
||||
size_t namelen, const uint8_t *value,
|
||||
@@ -1831,7 +1814,6 @@ server_handle_header(isc_nmsocket_t *socket, const uint8_t *name,
|
||||
const char path[] = ":path";
|
||||
const char method[] = ":method";
|
||||
const char scheme[] = ":scheme";
|
||||
const char accept[] = "accept";
|
||||
const char content_length[] = "Content-Length";
|
||||
const char content_type[] = "Content-Type";
|
||||
|
||||
@@ -1852,9 +1834,6 @@ server_handle_header(isc_nmsocket_t *socket, const uint8_t *name,
|
||||
} else if (!was_error && HEADER_MATCH(content_type, name, namelen)) {
|
||||
code = server_handle_content_type_header(socket, value,
|
||||
valuelen);
|
||||
} else if (!was_error &&
|
||||
HEADER_MATCH(accept, (const char *)name, namelen)) {
|
||||
code = server_handle_accept_header(socket, value, valuelen);
|
||||
}
|
||||
|
||||
return (code);
|
||||
|
Reference in New Issue
Block a user