GC_Http::buildCookieHeader()
最后更新于:2021-12-01 11:14:15
GC_( array$r)Takes the arguments for a ::request() and checks for the cookie array.
参数
- $r
-
(array) (Required) Full array of args passed into ::request()
源文件
文件: gc-includes/class-http.php
public static function buildCookieHeader( &$r ) { // phpcs:ignore GeChiUI.NamingConventions.ValidFunctionName.MethodNameInvalid
if ( ! empty( $r['cookies'] ) ) {
// Upgrade any name => value cookie pairs to GC_HTTP_Cookie instances.
foreach ( $r['cookies'] as $name => $value ) {
if ( ! is_object( $value ) ) {
$r['cookies'][ $name ] = new GC_Http_Cookie(
array(
'name' => $name,
'value' => $value,
)
);
}
}
$cookies_header = '';
foreach ( (array) $r['cookies'] as $cookie ) {
$cookies_header .= $cookie->getHeaderValue() . '; ';
}
$cookies_header = substr( $cookies_header, 0, -2 );
$r['headers']['cookie'] = $cookies_header;
}
}