MCPcopy Index your code
hub / github.com/google/go-github / parseRate

Function parseRate

github/github.go:1068–1088  ·  view source on GitHub ↗

parseRate parses the rate related headers.

(r *http.Response)

Source from the content-addressed store, hash-verified

1066
1067// parseRate parses the rate related headers.
1068func parseRate(r *http.Response) Rate {
1069 var rate Rate
1070 if limit := r.Header.Get(HeaderRateLimit); limit != "" {
1071 rate.Limit, _ = strconv.Atoi(limit)
1072 }
1073 if remaining := r.Header.Get(HeaderRateRemaining); remaining != "" {
1074 rate.Remaining, _ = strconv.Atoi(remaining)
1075 }
1076 if used := r.Header.Get(HeaderRateUsed); used != "" {
1077 rate.Used, _ = strconv.Atoi(used)
1078 }
1079 if reset := r.Header.Get(HeaderRateReset); reset != "" {
1080 if v, _ := strconv.ParseInt(reset, 10, 64); v != 0 {
1081 rate.Reset = Timestamp{time.Unix(v, 0)}
1082 }
1083 }
1084 if resource := r.Header.Get(HeaderRateResource); resource != "" {
1085 rate.Resource = resource
1086 }
1087 return rate
1088}
1089
1090// parseSecondaryRate parses the secondary rate related headers,
1091// and returns the time to retry after.

Callers 4

newResponseFunction · 0.85
CheckResponseFunction · 0.85

Calls 1

GetMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…