Skip to content

Commit

Permalink
Correct formatting for 'X-Forwarded-For'
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanLCox1 committed Jun 17, 2024
1 parent 41f35cb commit 539e8fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/NativeSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ private function buildRequest(Request $smartyRequest)
if ($smartyRequest->getReferer() != null)
curl_setopt($ch, CURLOPT_REFERER, $smartyRequest->getReferer());
if ($this->ip != null) {
curl_setopt($ch, CURLOPT_HTTPHEADER, array("X_FORWARDED_FOR: $this->ip"));
$smartyRequest->setHeader('X_FORWARDED_FOR', $this->ip);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Forwarded-For: $this->ip"));
$smartyRequest->setHeader('X-Forwarded-For', $this->ip);
}

return $ch;
Expand Down
4 changes: 2 additions & 2 deletions tests/XForwardedForTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function testNativeSetOnQuery() {

$sender->send($request);

$this->assertEquals("0.0.0.0", $request->getHeaders()["X_FORWARDED_FOR"]);
$this->assertEquals("0.0.0.0", $request->getHeaders()["X-Forwarded-For"]);
}

public function testNativeNotSet() {
Expand All @@ -34,6 +34,6 @@ public function testNativeNotSet() {
$sender->send($request);
$headers = $request->getHeaders();

$this->assertEquals(false, array_key_exists("X_FORWARDED_FOR", $headers));
$this->assertEquals(false, array_key_exists("X-Forwarded-For", $headers));
}
}

0 comments on commit 539e8fb

Please sign in to comment.