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

FsockopenTest: add regression test for HTTP string #520

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/quicktest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ jobs:
- name: Access localhost on port 9002
run: curl -i http://localhost:9002

- name: Show available locales
run: locale -a

- name: Show PHPUnit version
run: vendor/bin/phpunit --version

Expand Down
29 changes: 29 additions & 0 deletions tests/Transport/FsockopenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,33 @@ public function testContentLengthHeader() {
public function checkContentLengthHeader($headers) {
$this->assertStringContainsString('Content-Length: 0', $headers);
}

/**
* Issue #335/#339.
*/
public function testHTTPVersionHeader() {
// Remember the original locale.
$locale = setlocale(LC_NUMERIC, 0);

// Set the locale to one using commas for the decimal point.
setlocale(LC_NUMERIC, 'de_DE@euro', 'de_DE', 'de', 'ge');

// Make sure the locale was changed.
$this->assertNotSame($locale, setlocale(LC_NUMERIC, 0), 'Changing the locale failed');

$hooks = new Requests_Hooks();
$hooks->register('fsockopen.after_headers', array($this, 'checkHTTPVersionHeader'));

Requests::post(httpbin('/post'), array(), array(), $this->getOptions(array('hooks' => $hooks)));

// Reset the locale.
setlocale(LC_NUMERIC, $locale);
}

/**
* Issue #335/#339.
*/
public function checkHTTPVersionHeader($headers) {
$this->assertStringContainsString('HTTP/1.1', $headers, 'HTTP header is influenced by the system locale');
}
}