diff --git a/src/mantle/http-client/class-pending-request.php b/src/mantle/http-client/class-pending-request.php index b75155846..4251c7b00 100644 --- a/src/mantle/http-client/class-pending-request.php +++ b/src/mantle/http-client/class-pending-request.php @@ -228,7 +228,7 @@ public function body_format( string $format ) { * @return static */ public function content_type( string $content_type ) { - return $this->with_headers( [ 'Content-Type' => $content_type ] ); + return $this->with_header( 'Content-Type', $content_type, true ); } /** diff --git a/tests/http-client/test-http-client.php b/tests/http-client/test-http-client.php index 2a6280ca0..094079e4c 100644 --- a/tests/http-client/test-http-client.php +++ b/tests/http-client/test-http-client.php @@ -439,4 +439,11 @@ public function test_conditionable_unless_request() { $this->assertEquals( 'Bar', $request->header( 'X-Foo' ) ); } + + public function test_headers_as_form() { + $request = $this->http_factory + ->as_form(); + + $this->assertEquals( 'application/x-www-form-urlencoded', $request->header( 'Content-Type' ) ); + } }