diff --git a/CHANGELOG.md b/CHANGELOG.md index 5504d12f..3c68505b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ENHANCEMENTS: -* data-source/http: `response_body_base64_std` has been added and contains a standard base64 encoding of the response body ([#158](https://github.com/hashicorp/terraform-provider-http/pull/158)). +* data-source/http: `response_body_base64` has been added and contains a standard base64 encoding of the response body ([#158](https://github.com/hashicorp/terraform-provider-http/pull/158)). * data-source/http: Replaced issuing warning on the basis of possible non-text `Content-Type` with issuing warning if response body does not contain valid UTF-8. ([#158](https://github.com/hashicorp/terraform-provider-http/pull/158)). ## 3.1.0 (August 30, 2022) diff --git a/docs/data-sources/http.md b/docs/data-sources/http.md index 9dd3ffa5..6e8b7272 100644 --- a/docs/data-sources/http.md +++ b/docs/data-sources/http.md @@ -152,6 +152,6 @@ resource "null_resource" "example" { - `body` (String, Deprecated) The response body returned as a string. **NOTE**: This is deprecated, use `response_body` instead. - `id` (String) The URL used for the request. - `response_body` (String) The response body returned as a string. -- `response_body_base64_std` (String) The response body encoded as base64 (standard) as defined in [RFC 4648](https://datatracker.ietf.org/doc/html/rfc4648#section-4). +- `response_body_base64` (String) The response body encoded as base64 (standard) as defined in [RFC 4648](https://datatracker.ietf.org/doc/html/rfc4648#section-4). - `response_headers` (Map of String) A map of response header field names and values. Duplicate headers are concatenated according to [RFC2616](https://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2). - `status_code` (Number) The HTTP response status code. \ No newline at end of file diff --git a/internal/provider/data_source_http.go b/internal/provider/data_source_http.go index da1965de..c57cda30 100644 --- a/internal/provider/data_source_http.go +++ b/internal/provider/data_source_http.go @@ -104,7 +104,7 @@ your control should be treated as untrustworthy.`, DeprecationMessage: "Use response_body instead", }, - "response_body_base64_std": { + "response_body_base64": { Description: "The response body encoded as base64 (standard) as defined in [RFC 4648](https://datatracker.ietf.org/doc/html/rfc4648#section-4).", Type: types.StringType, Computed: true, @@ -232,6 +232,6 @@ type modelV0 struct { ResponseHeaders types.Map `tfsdk:"response_headers"` ResponseBody types.String `tfsdk:"response_body"` Body types.String `tfsdk:"body"` - ResponseBodyBase64Std types.String `tfsdk:"response_body_base64_std"` + ResponseBodyBase64Std types.String `tfsdk:"response_body_base64"` StatusCode types.Int64 `tfsdk:"status_code"` } diff --git a/internal/provider/data_source_http_test.go b/internal/provider/data_source_http_test.go index 572a7474..3c319c0d 100644 --- a/internal/provider/data_source_http_test.go +++ b/internal/provider/data_source_http_test.go @@ -363,7 +363,7 @@ func TestDataSource_ResponseBodyText(t *testing.T) { }`, svr.URL), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("data.http.http_test", "response_body", "你好世界"), - resource.TestCheckResourceAttr("data.http.http_test", "response_body_base64_std", "5L2g5aW95LiW55WM"), + resource.TestCheckResourceAttr("data.http.http_test", "response_body_base64", "5L2g5aW95LiW55WM"), ), }, }, @@ -394,7 +394,7 @@ func TestDataSource_ResponseBodyBinary(t *testing.T) { Check: resource.ComposeTestCheckFunc( // Note the replacement character in the string representation in `response_body`. resource.TestCheckResourceAttr("data.http.http_test", "response_body", "GIF89a\x01\x00\x01\x00�\x00\x00\x00\x00\x00\x00\x00\x00!�\x04\x01\x00\x00\x00\x00,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02D\x01\x00;"), - resource.TestCheckResourceAttr("data.http.http_test", "response_body_base64_std", "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="), + resource.TestCheckResourceAttr("data.http.http_test", "response_body_base64", "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="), ), }, },