Skip to content

Commit

Permalink
Fix http-client content_type method
Browse files Browse the repository at this point in the history
  • Loading branch information
nlemoine committed Jul 23, 2023
1 parent ac9159d commit fca0611
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/mantle/http-client/class-pending-request.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

/**
Expand Down
7 changes: 7 additions & 0 deletions tests/http-client/test-http-client.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) );
}
}

0 comments on commit fca0611

Please sign in to comment.