| 581 | type cacheControl map[string]string |
| 582 | |
| 583 | func parseCacheControl(headers http.Header) cacheControl { |
| 584 | cc := cacheControl{} |
| 585 | ccHeader := headers.Get("Cache-Control") |
| 586 | for _, part := range strings.Split(ccHeader, ",") { |
| 587 | part = strings.Trim(part, " ") |
| 588 | if part == "" { |
| 589 | continue |
| 590 | } |
| 591 | if strings.ContainsRune(part, '=') { |
| 592 | keyval := strings.Split(part, "=") |
| 593 | cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",") |
| 594 | } else { |
| 595 | cc[part] = "" |
| 596 | } |
| 597 | } |
| 598 | return cc |
| 599 | } |
| 600 | |
| 601 | // CacheExpires helper function to determine remaining time before repeating a request. |
| 602 | func CacheExpires(r *http.Response) time.Time { |