Skip to content

Commit 5d69bcf

Browse files
authored
Set the User-Agent regardless of GET or POST (#382)
1 parent c146b71 commit 5d69bcf

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [unreleased]
8+
* User-Agent is set for any HTTP method in fetchURL() (not just POST). #382
89
* Update visibility of getWellKnownConfigValue to protected. #363
910
* Fixed issue on authentication for php8. #354
1011
* Support for signed and encrypted UserInfo response. #305

src/OpenIDConnectClient.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,6 @@ protected function fetchURL(string $url, string $post_body = null, array $header
13671367
// Allows to keep the POST method even after redirect
13681368
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
13691369
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_body);
1370-
curl_setopt($ch, CURLOPT_USERAGENT, $this->getUserAgent());
13711370

13721371
// Default content type is form encoded
13731372
$content_type = 'application/x-www-form-urlencoded';
@@ -1381,6 +1380,9 @@ protected function fetchURL(string $url, string $post_body = null, array $header
13811380
$headers[] = "Content-Type: $content_type";
13821381
}
13831382

1383+
// Set the User-Agent
1384+
curl_setopt($ch, CURLOPT_USERAGENT, $this->getUserAgent());
1385+
13841386
// If we set some headers include them
13851387
if(count($headers) > 0) {
13861388
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

0 commit comments

Comments
 (0)