File tests/http.inc.php changed (mode: 100644) (index a512475..d004130) |
... |
... |
function prepare_http() |
30 |
30 |
/* |
/* |
31 |
31 |
* Data is an array |
* Data is an array |
32 |
32 |
*/ |
*/ |
33 |
|
$http_handles = array(); |
|
34 |
33 |
function do_req($url, &$data, &$headers) |
function do_req($url, &$data, &$headers) |
35 |
34 |
{ |
{ |
36 |
35 |
global $test_ua, $test_referer; |
global $test_ua, $test_referer; |
37 |
36 |
global $cookie_jar; |
global $cookie_jar; |
38 |
|
global $http_handles; |
|
|
37 |
|
static $http_handles = array(); |
39 |
38 |
global $http_client; |
global $http_client; |
40 |
39 |
global $_testns; |
global $_testns; |
|
40 |
|
global $rg_log_sid; |
41 |
41 |
|
|
42 |
42 |
if (!isset($http_client)) |
if (!isset($http_client)) |
43 |
43 |
$http_client = $_testns; |
$http_client = $_testns; |
|
... |
... |
function do_req($url, &$data, &$headers) |
60 |
60 |
else |
else |
61 |
61 |
$url .= '&rg_debug=1'; |
$url .= '&rg_debug=1'; |
62 |
62 |
$url .= '&tid=' . rg_id(10); // to easy identify requests in the logs |
$url .= '&tid=' . rg_id(10); // to easy identify requests in the logs |
|
63 |
|
$url .= '&_testns=' . $_testns; |
|
64 |
|
$url .= '&rg_log_sid=' . $rg_log_sid; |
63 |
65 |
|
|
64 |
66 |
rg_log_ml("do_req url[$url] data=" . print_r($data, TRUE) |
rg_log_ml("do_req url[$url] data=" . print_r($data, TRUE) |
65 |
67 |
. "headers=" . print_r($headers, TRUE)); |
. "headers=" . print_r($headers, TRUE)); |
|
... |
... |
function do_req($url, &$data, &$headers) |
78 |
80 |
curl_setopt($c, CURLOPT_POSTFIELDS, $data); |
curl_setopt($c, CURLOPT_POSTFIELDS, $data); |
79 |
81 |
} else { |
} else { |
80 |
82 |
curl_setopt($c, CURLOPT_POST, 0); |
curl_setopt($c, CURLOPT_POST, 0); |
81 |
|
curl_setopt($c, CURLOPT_POSTFIELDS, ''); |
|
82 |
83 |
} |
} |
83 |
84 |
curl_setopt($c, CURLOPT_RETURNTRANSFER, TRUE); |
curl_setopt($c, CURLOPT_RETURNTRANSFER, TRUE); |
84 |
85 |
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1); |
curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1); |
File tests/http_304.php added (mode: 100644) (index 0000000..4d5f026) |
|
1 |
|
<?php |
|
2 |
|
error_reporting(E_ALL | E_STRICT); |
|
3 |
|
ini_set('track_errors', 'On'); |
|
4 |
|
|
|
5 |
|
$rg_cache_debug = TRUE; |
|
6 |
|
$test_normal = TRUE; |
|
7 |
|
|
|
8 |
|
$INC = dirname(__FILE__) . '/../inc'; |
|
9 |
|
require_once(dirname(__FILE__) . '/config.php'); |
|
10 |
|
require_once($INC . '/init.inc.php'); |
|
11 |
|
require_once($INC . '/util.inc.php'); |
|
12 |
|
require_once('helpers.inc.php'); |
|
13 |
|
require_once('http.inc.php'); |
|
14 |
|
|
|
15 |
|
rg_log_set_file('http_304.log'); |
|
16 |
|
|
|
17 |
|
require_once('common.php'); |
|
18 |
|
|
|
19 |
|
$_testns = 'http_304'; |
|
20 |
|
|
|
21 |
|
prepare_http(); |
|
22 |
|
|
|
23 |
|
rg_log(''); |
|
24 |
|
rg_log_enter('Loading main page...'); |
|
25 |
|
$data = array(); $headers = array(); |
|
26 |
|
$r = do_req($test_url . '/', $data, $headers); |
|
27 |
|
if (!stristr($r['header'], 'Content-Encoding: gzip')) { |
|
28 |
|
rg_log_ml('headers: ' . print_r($r['header'], TRUE)); |
|
29 |
|
rg_log('Content is not compressed!'); |
|
30 |
|
exit(1); |
|
31 |
|
} |
|
32 |
|
if (!stristr($r['header'], "\n" . 'ETag: ')) { |
|
33 |
|
rg_log_ml('headers: ' . print_r($r['header'], TRUE)); |
|
34 |
|
rg_log('ETag is not present!'); |
|
35 |
|
exit(1); |
|
36 |
|
} |
|
37 |
|
rg_log_ml('Headers: ' . print_r($r['header'], TRUE)); |
|
38 |
|
$x = explode("\nETag: ", $r['header'], 2); |
|
39 |
|
$y = explode("\n", $x[1], 2); |
|
40 |
|
$etag = trim($y[0]); |
|
41 |
|
rg_log_exit(); |
|
42 |
|
|
|
43 |
|
|
|
44 |
|
rg_log(''); |
|
45 |
|
rg_log_enter('Loading main page...'); |
|
46 |
|
$data = array(); $headers = array('If-None-Match: ' . $etag); |
|
47 |
|
$r = do_req($test_url . '/', $data, $headers); |
|
48 |
|
$x = explode("\n", $r['header'], 2); |
|
49 |
|
$x = trim($x[0]); |
|
50 |
|
if (!strstr($x, ' 304 ')) { |
|
51 |
|
rg_log_ml('headers: ' . print_r($r['header'], TRUE)); |
|
52 |
|
rg_log('We did not got 304 answer (but [' . $x . '])!'); |
|
53 |
|
exit(1); |
|
54 |
|
} |
|
55 |
|
rg_log_exit(); |
|
56 |
|
|
|
57 |
|
rg_log('OK!'); |
File tests/http_top.php changed (mode: 100644) (index c3613a8..c126695) |
... |
... |
$_list = array("features", "discover", "download", "pricing", "tos", |
27 |
27 |
foreach ($_list as $op) { |
foreach ($_list as $op) { |
28 |
28 |
rg_log("Loading $op page..."); |
rg_log("Loading $op page..."); |
29 |
29 |
$data = array(); |
$data = array(); |
30 |
|
$r = do_req($test_url . "/op/$op?t=http_top", $data, $headers); |
|
|
30 |
|
$r = do_req($test_url . '/op/' . $op, $data, $headers); |
31 |
31 |
} |
} |
32 |
32 |
|
|
33 |
33 |
rg_log("OK!"); |
rg_log("OK!"); |