1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

gcoap_forward_proxy: copy Max-Age from forwarded Valid if it exists

This commit is contained in:
Martine Lenders 2022-08-18 12:05:26 +02:00
parent 2dd59236c8
commit 9bc0454d99
No known key found for this signature in database
GPG Key ID: 2134D77A5336DD80

View File

@ -210,8 +210,19 @@ static void _forward_resp_handler(const gcoap_request_memo_t *memo,
/* check if we can just send 2.03 Valid instead */
if ((cep->req_etag_len == coap_opt_get_opaque(pdu, COAP_OPT_ETAG, &resp_etag)) &&
(memcmp(cep->req_etag, resp_etag, cep->req_etag_len) == 0)) {
uint32_t max_age;
if (coap_opt_get_uint(pdu, COAP_OPT_MAX_AGE, &max_age) < 0) {
/* use default,
* see https://datatracker.ietf.org/doc/html/rfc7252#section-5.10.5 */
max_age = 60U;
}
gcoap_resp_init(pdu, (uint8_t *)pdu->hdr, buf_len, COAP_CODE_VALID);
coap_opt_add_opaque(pdu, COAP_OPT_ETAG, cep->req_etag, cep->req_etag_len);
if (max_age != 60U) {
/* only include Max-Age option if it is not the default value */
coap_opt_add_uint(pdu, COAP_OPT_MAX_AGE, max_age);
}
coap_opt_finish(pdu, COAP_OPT_FINISH_NONE);
}
}