Skip to content

Commit

Permalink
Support cookies on Curl requests
Browse files Browse the repository at this point in the history
  • Loading branch information
chibimagic committed Jun 5, 2014
1 parent 69cbbc6 commit ac0a7df
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion WebDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static function WaitUntil($callback, $parameters, $expected) {
return $actual;
}

public static function Curl($http_type, $full_url, $payload = null, $escape_payload = true) {
public static function Curl($http_type, $full_url, $payload = null, $escape_payload = true, $cookies = array()) {
$curl = curl_init($full_url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $http_type);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
Expand All @@ -99,6 +99,10 @@ public static function Curl($http_type, $full_url, $payload = null, $escape_payl
}
curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
}
if (!empty($cookies)) {
$cookie_string = http_build_query($cookies, '', '; ');
curl_setopt($curl, CURLOPT_COOKIE, $cookie_string);
}
WebDriver::LogDebug($http_type, $full_url, $payload);
$full_response = curl_exec($curl);
WebDriver::LogDebug($full_response);
Expand Down

0 comments on commit ac0a7df

Please sign in to comment.