MCPcopy
hub / github.com/syncthing/syncthing / checkResponse

Function checkResponse

cmd/syncthing/cli/client.go:159–173  ·  view source on GitHub ↗
(response *http.Response)

Source from the content-addressed store, hash-verified

157var errNotFound = errors.New("invalid endpoint or API call")
158
159func checkResponse(response *http.Response) error {
160 if response.StatusCode == http.StatusNotFound {
161 return errNotFound
162 } else if response.StatusCode == http.StatusUnauthorized {
163 return errors.New("invalid API key")
164 } else if response.StatusCode != http.StatusOK {
165 data, err := responseToBArray(response)
166 if err != nil {
167 return err
168 }
169 body := strings.TrimSpace(string(data))
170 return fmt.Errorf("unexpected HTTP status returned: %s\n%s", response.Status, body)
171 }
172 return nil
173}

Callers 1

DoMethod · 0.85

Calls 2

responseToBArrayFunction · 0.85
NewMethod · 0.65

Tested by

no test coverage detected