dav_get_timeout: If the Timeout: header exists, return a time_t * when this lock is expected to expire. Otherwise, return * a time_t of DAV_TIMEOUT_INFINITE. * * It's unclear if DAV clients are required to understand * Seconds-xxx and Infinity time values. We assume that they do. * In addition, for now, that's all we understand, too. */
| 540 | * In addition, for now, that's all we understand, too. |
| 541 | */ |
| 542 | DAV_DECLARE(time_t) dav_get_timeout(request_rec *r) |
| 543 | { |
| 544 | time_t now, expires = DAV_TIMEOUT_INFINITE; |
| 545 | |
| 546 | const char *timeout_const = apr_table_get(r->headers_in, "Timeout"); |
| 547 | const char *timeout = apr_pstrdup(r->pool, timeout_const), *val; |
| 548 | |
| 549 | if (timeout == NULL) |
| 550 | return DAV_TIMEOUT_INFINITE; |
| 551 | |
| 552 | /* Use the first thing we understand, or infinity if |
| 553 | * we don't understand anything. |
| 554 | */ |
| 555 | |
| 556 | while ((val = ap_getword_white(r->pool, &timeout)) && strlen(val)) { |
| 557 | if (!strncmp(val, "Infinite", 8)) { |
| 558 | return DAV_TIMEOUT_INFINITE; |
| 559 | } |
| 560 | |
| 561 | if (!strncmp(val, "Second-", 7)) { |
| 562 | val += 7; |
| 563 | /* ### We need to handle overflow better: |
| 564 | * ### timeout will be <= 2^32 - 1 |
| 565 | */ |
| 566 | expires = atol(val); |
| 567 | now = time(NULL); |
| 568 | return now + expires; |
| 569 | } |
| 570 | } |
| 571 | |
| 572 | return DAV_TIMEOUT_INFINITE; |
| 573 | } |
| 574 | |
| 575 | /* --------------------------------------------------------------- |
| 576 | ** |
no test coverage detected