GC_Http::normalize_cookies()
最后更新于:2021-12-01 11:13:50
GC_( array$cookies)Normalizes cookies for using in Requests.
参数
- $cookies
-
(array) (Required) Array of cookies to send with the request.
响应
(Requests_Cookie_Jar) Cookie holder object.
源文件
文件: gc-includes/class-http.php
public static function normalize_cookies( $cookies ) {
$cookie_jar = new Requests_Cookie_Jar();
foreach ( $cookies as $name => $value ) {
if ( $value instanceof GC_Http_Cookie ) {
$cookie_jar[ $value->name ] = new Requests_Cookie( $value->name, $value->value, $value->get_attributes(), array( 'host-only' => $value->host_only ) );
} elseif ( is_scalar( $value ) ) {
$cookie_jar[ $name ] = new Requests_Cookie( $name, $value );
}
}
return $cookie_jar;
}