MCPcopy
hub / github.com/perkeep/perkeep / expect2XX

Method expect2XX

pkg/client/client.go:1218–1227  ·  view source on GitHub ↗

expect2XX will doReqGated and promote HTTP response codes outside of the 200-299 range to a non-nil error containing the response body.

(req *http.Request)

Source from the content-addressed store, hash-verified

1216// expect2XX will doReqGated and promote HTTP response codes outside of
1217// the 200-299 range to a non-nil error containing the response body.
1218func (c *Client) expect2XX(req *http.Request) (*http.Response, error) {
1219 res, err := c.doReqGated(req)
1220 if err == nil && (res.StatusCode < 200 || res.StatusCode > 299) {
1221 buf := new(bytes.Buffer)
1222 io.CopyN(buf, res.Body, 1<<20)
1223 res.Body.Close()
1224 return res, fmt.Errorf("client: got status code %d from URL %s; body %s", res.StatusCode, req.URL.String(), buf.String())
1225 }
1226 return res, err
1227}
1228
1229func (c *Client) doReqGated(req *http.Request) (*http.Response, error) {
1230 c.httpGate.Start()

Callers 9

GetRecentPermanodesMethod · 0.95
GetPermanodesWithAttrMethod · 0.95
DescribeMethod · 0.95
GetClaimsMethod · 0.95
queryMethod · 0.95
FileHasContentsMethod · 0.95
GetJSONMethod · 0.95
postMethod · 0.95
NewFromShareRootFunction · 0.80

Calls 3

doReqGatedMethod · 0.95
CloseMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected