Skip to content

Commit 010b119

Browse files
committed
user agent
1 parent fff5a5d commit 010b119

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

qiniu/conf.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
global $SDK_VER;
23

34
global $QINIU_UP_HOST;
45
global $QINIU_RS_HOST;
@@ -7,6 +8,8 @@
78
global $QINIU_ACCESS_KEY;
89
global $QINIU_SECRET_KEY;
910

11+
$SDK_VER = "6.1.9";
12+
1013
$QINIU_UP_HOST = 'http://up.qiniu.com';
1114
$QINIU_RS_HOST = 'http://rs.qbox.me';
1215
$QINIU_RSF_HOST = 'http://rsf.qbox.me';

qiniu/http.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
require_once("auth_digest.php");
4+
require_once("conf.php");
45

56
// --------------------------------------------------------------------------------
67
// class Qiniu_Error
@@ -27,12 +28,14 @@ class Qiniu_Request
2728
public $URL;
2829
public $Header;
2930
public $Body;
31+
public $UA;
3032

3133
public function __construct($url, $body)
3234
{
3335
$this->URL = $url;
3436
$this->Header = array();
3537
$this->Body = $body;
38+
$this->UA = Qiniu_UserAgent();
3639
}
3740
}
3841

@@ -111,6 +114,7 @@ function Qiniu_Client_do($req) // => ($resp, $error)
111114
$ch = curl_init();
112115
$url = $req->URL;
113116
$options = array(
117+
CURLOPT_USERAGENT => $req->UA,
114118
CURLOPT_RETURNTRANSFER => true,
115119
CURLOPT_SSL_VERIFYPEER => false,
116120
CURLOPT_SSL_VERIFYHOST => false,
@@ -278,6 +282,21 @@ function Qiniu_Build_MultipartForm($fields, $files) // => ($contentType, $body)
278282
return array($contentType, $body);
279283
}
280284

285+
function Qiniu_UserAgent() {
286+
global $SDK_VER;
287+
$sdkInfo = "QiniuPHP/$SDK_VER";
288+
289+
$systemInfo = php_uname("s");
290+
$machineInfo = php_uname("m");
291+
292+
$envInfo = "($systemInfo/$machineInfo)";
293+
294+
$phpVer = phpversion();
295+
296+
$ua = "$sdkInfo $envInfo PHP/$phpVer";
297+
return $ua;
298+
}
299+
281300
function Qiniu_escapeQuotes($str)
282301
{
283302
$find = array("\\", "\"");

0 commit comments

Comments
 (0)