Skip to content

Commit cfc9a46

Browse files
committed
Add a method to test if the request comes from ajax
1 parent 84cc9bf commit cfc9a46

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/WaterPipe/HTTP/Request/Request.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ public function setBody(RequestData $body): void
129129
$this->_body = $body;
130130
}
131131

132+
/**
133+
* Checks if the current request is from Ajax.
134+
*
135+
* @return bool
136+
*/
137+
public function isAjax(): bool
138+
{
139+
return (!empty($_SERVER["HTTP_X_REQUESTED_WITH"]) && strtolower($_SERVER["HTTP_X_REQUESTED_WITH"]) === "xmlhttprequest");
140+
}
141+
132142
/**
133143
* Captures the current request.
134144
*

0 commit comments

Comments
 (0)