Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data-source/http: Ensure HTTP request body is not sent unless configured #390

Merged
merged 1 commit into from
Feb 29, 2024

Commits on Feb 29, 2024

  1. data-source/http: Ensure HTTP request body is not sent unless configured

    Reference: #388
    
    Previously the HTTP request would unexpectedly always contain a body for all requests. Certain HTTP server implementations are sensitive to this data existing if it is not expected. Requests now only contain a request body if the `request_body` attribute is explicitly set. To exactly preserve the previous behavior, set `request_body = ""`.
    
    Added new acceptance testing for `request_body` handling. Go net/http server implementations seem to ignore this problematic situation (or it was not easy to determine), so also verified with a real world configuration using a temporary acceptance test as well as manually running Terraform using a development build containing these changes:
    
    ```
    // Reference: #388
    func TestDataSource_RequestBody_Null(t *testing.T) {
    	t.Parallel()
    
    	resource.Test(t, resource.TestCase{
    		ProtoV5ProviderFactories: protoV5ProviderFactories(),
    		Steps: []resource.TestStep{
    			{
    				Config: `
    					data "http" "test" {
    						url = "https://www.cloudflare.com/ips-v4"
    					}`,
    				Check: resource.ComposeAggregateTestCheckFunc(
    					resource.TestCheckResourceAttr("data.http.test", "status_code", "200"),
    				),
    			},
    		},
    	})
    }
    ```
    
    This real world acceptance test is not added as the server may change its implementation in the future.
    bflad committed Feb 29, 2024
    Configuration menu
    Copy the full SHA
    a496401 View commit details
    Browse the repository at this point in the history