Request server for current bucket policy.
(ctx context.Context, bucketName string)
| 130 | |
| 131 | // Request server for current bucket policy. |
| 132 | func (c *Client) getBucketPolicy(ctx context.Context, bucketName string) (string, error) { |
| 133 | // Get resources properly escaped and lined up before |
| 134 | // using them in http request. |
| 135 | urlValues := make(url.Values) |
| 136 | urlValues.Set("policy", "") |
| 137 | |
| 138 | // Execute GET on bucket to list objects. |
| 139 | resp, err := c.executeMethod(ctx, http.MethodGet, requestMetadata{ |
| 140 | bucketName: bucketName, |
| 141 | queryValues: urlValues, |
| 142 | contentSHA256Hex: emptySHA256Hex, |
| 143 | }) |
| 144 | |
| 145 | defer closeResponse(resp) |
| 146 | if err != nil { |
| 147 | return "", err |
| 148 | } |
| 149 | |
| 150 | if resp != nil { |
| 151 | if resp.StatusCode != http.StatusOK { |
| 152 | return "", httpRespToErrorResponse(resp, bucketName, "") |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | bucketPolicyBuf, err := io.ReadAll(resp.Body) |
| 157 | if err != nil { |
| 158 | return "", err |
| 159 | } |
| 160 | |
| 161 | policy := string(bucketPolicyBuf) |
| 162 | return policy, err |
| 163 | } |
no test coverage detected