MCPcopy Create free account
hub / github.com/imroc/req / isReplayable

Function isReplayable

http_request.go:124–138  ·  view source on GitHub ↗
(r *http.Request)

Source from the content-addressed store, hash-verified

122}
123
124func isReplayable(r *http.Request) bool {
125 if r.Body == nil || r.Body == NoBody || r.GetBody != nil {
126 switch valueOrDefault(r.Method, "GET") {
127 case "GET", "HEAD", "OPTIONS", "TRACE":
128 return true
129 }
130 // The Idempotency-Key, while non-standard, is widely used to
131 // mean a POST or other request is idempotent. See
132 // https://golang.org/issue/19943#issuecomment-421092421
133 if headerHas(r.Header, "Idempotency-Key") || headerHas(r.Header, "X-Idempotency-Key") {
134 return true
135 }
136 }
137 return false
138}
139
140func reqExpectsContinue(r *http.Request) bool {
141 return hasToken(headerGet(r.Header, "Expect"), "100-continue")

Callers 1

shouldRetryRequestMethod · 0.85

Calls 2

valueOrDefaultFunction · 0.85
headerHasFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…