-
Notifications
You must be signed in to change notification settings - Fork 9
/
Utils.php
51 lines (44 loc) · 1.06 KB
/
Utils.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace Guzzle\Http;
use Guzzle\Common\Version;
use Guzzle\Http\Curl\CurlVersion;
/**
* HTTP utility class
*/
class Utils
{
/**
* @var string
*/
protected static $userAgent;
/**
* Create an RFC 1123 HTTP-Date from various date values
*
* @param string|int $date Date to convert
*
* @return string
*/
public static function getHttpDate($date)
{
if (!is_numeric($date)) {
$date = strtotime($date);
}
return gmdate('D, d M Y H:i:s', $date) . ' GMT';
}
/**
* Get the default User-Agent to add to requests sent through the library
*
* @return string
*/
public static function getDefaultUserAgent()
{
if (!self::$userAgent) {
$curl = CurlVersion::getInstance();
self::$userAgent = sprintf('Guzzle/%s curl/%s PHP/%s openssl/%s',
Version::VERSION, $curl->get('version'), PHP_VERSION,
$curl->get('ssl_version')
);
}
return self::$userAgent;
}
}