parseTokenExpiration parses the TokenExpiration related headers. Returns 0001-01-01 if the header is not defined or could not be parsed.
(r *http.Response)
| 1114 | // parseTokenExpiration parses the TokenExpiration related headers. |
| 1115 | // Returns 0001-01-01 if the header is not defined or could not be parsed. |
| 1116 | func parseTokenExpiration(r *http.Response) Timestamp { |
| 1117 | if v := r.Header.Get(headerTokenExpiration); v != "" { |
| 1118 | if t, err := time.Parse("2006-01-02 15:04:05 MST", v); err == nil { |
| 1119 | return Timestamp{t.Local()} |
| 1120 | } |
| 1121 | // Some tokens include the timezone offset instead of the timezone. |
| 1122 | // https://github.com/google/go-github/issues/2649 |
| 1123 | if t, err := time.Parse("2006-01-02 15:04:05 -0700", v); err == nil { |
| 1124 | return Timestamp{t.Local()} |
| 1125 | } |
| 1126 | } |
| 1127 | return Timestamp{} // 0001-01-01 00:00:00 |
| 1128 | } |
| 1129 | |
| 1130 | type requestContext uint8 |
| 1131 |
searching dependent graphs…