(ctx context.Context)
| 1027 | } |
| 1028 | |
| 1029 | func (c *Client) discoveryResp(ctx context.Context) (*http.Response, error) { |
| 1030 | // If the path is just "" or "/", do discovery against |
| 1031 | // the URL to see which path we should actually use. |
| 1032 | req := c.newRequest(ctx, "GET", c.discoRoot(), nil) |
| 1033 | req.Header.Set("Accept", "text/x-camli-configuration") |
| 1034 | res, err := c.doReqGated(req) |
| 1035 | if err != nil { |
| 1036 | return nil, err |
| 1037 | } |
| 1038 | if res.StatusCode != 200 { |
| 1039 | res.Body.Close() |
| 1040 | errMsg := fmt.Sprintf("got status %q from blobserver URL %q during configuration discovery", res.Status, c.discoRoot()) |
| 1041 | if res.StatusCode == http.StatusUnauthorized && c.authErr != nil { |
| 1042 | errMsg = fmt.Sprintf("%v. %v", c.authErr, errMsg) |
| 1043 | } |
| 1044 | return nil, errors.New(errMsg) |
| 1045 | } |
| 1046 | // TODO(bradfitz): little weird in retrospect that we request |
| 1047 | // text/x-camli-configuration and expect to get back |
| 1048 | // text/javascript. Make them consistent. |
| 1049 | if ct := res.Header.Get("Content-Type"); ct != "text/javascript" { |
| 1050 | res.Body.Close() |
| 1051 | return nil, fmt.Errorf("Blobserver returned unexpected type %q from discovery", ct) |
| 1052 | } |
| 1053 | return res, nil |
| 1054 | } |
| 1055 | |
| 1056 | func (c *Client) doDiscovery() error { |
| 1057 | ctx := context.TODO() |
no test coverage detected