Skip to content

Commit 029ec01

Browse files
committed
test: verify SocketPost correctly rejects unsupported HTTP protocols
1 parent 9fa0393 commit 029ec01

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

tests/ReCaptcha/RequestMethod/SocketPostTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,4 +269,19 @@ public function testBadResponseReturnsErrorWhenHttp11(): void
269269

270270
$this->assertEquals('{"success": false, "error-codes": ["'.ReCaptcha::E_BAD_RESPONSE.'"]}', $response);
271271
}
272+
273+
public function testBadResponseReturnsErrorWhenHttp2(): void
274+
{
275+
SocketPostGlobalState::$fgetsResponses = [
276+
"HTTP/2.0 200 OK\r\n",
277+
"Content-Type: application/json\r\n",
278+
"\r\n",
279+
'RESPONSEBODY',
280+
];
281+
282+
$sp = new SocketPost();
283+
$response = $sp->submit(new RequestParameters('secret', 'response'));
284+
285+
$this->assertEquals('{"success": false, "error-codes": ["'.ReCaptcha::E_BAD_RESPONSE.'"]}', $response);
286+
}
272287
}

0 commit comments

Comments
 (0)