Fixed a problem with upload and ping test with nginx

This commit is contained in:
dosse91 2017-05-15 17:32:46 +02:00
parent 65be39ff90
commit ec61c14723
8 changed files with 23 additions and 16 deletions

2
.gitignore vendored
View file

@ -1,2 +0,0 @@
doc.odt
cktest.html

19
doc.md
View file

@ -1,7 +1,7 @@
# HTML5 Speedtest # HTML5 Speedtest
> by Federico Dossena > by Federico Dossena
> Version 4.2, April 26 2017 > Version 4.2.1, May 15 2017
> [https://github.com/adolfintel/speedtest/](https://github.com/adolfintel/speedtest/) > [https://github.com/adolfintel/speedtest/](https://github.com/adolfintel/speedtest/)
@ -31,7 +31,7 @@ To install the test on your server, upload the following files:
* `speedtest_worker.min.js` * `speedtest_worker.min.js`
* `garbage.php` * `garbage.php`
* `getIP.php` * `getIP.php`
* `empty.dat` * `empty.php`
You may also want to upload one of the examples to test it. You may also want to upload one of the examples to test it.
Later we'll see how to use the test without PHP. Later we'll see how to use the test without PHP.
@ -139,11 +139,11 @@ w.postMessage('start {"param1": "value1", "param2": "value2", ...}')
* __url_dl__: path to garbage.php or a large file to use for the download test * __url_dl__: path to garbage.php or a large file to use for the download test
* Default: `garbage.php` * Default: `garbage.php`
* __Important:__ path is relative to js file * __Important:__ path is relative to js file
* __url_ul__: path to ab empty file or empty.dat to use for the upload test * __url_ul__: path to ab empty file or empty.php to use for the upload test
* Default: `empty.dat` * Default: `empty.php`
* __Important:__ path is relative to js file * __Important:__ path is relative to js file
* __url_ping__: path to an empty file or empty.dat to use for the ping test * __url_ping__: path to an empty file or empty.php to use for the ping test
* Default: `empty.dat` * Default: `empty.php`
* __Important:__ path is relative to js file * __Important:__ path is relative to js file
* __url_getIp__: path to getIP.php or replacement * __url_getIp__: path to getIP.php or replacement
* Default: `getIP.php` * Default: `getIP.php`
@ -186,7 +186,7 @@ __Important:__ do not simply kill the worker while it's running, as it will leav
## Using the test without PHP ## Using the test without PHP
If your server does not support PHP, or you're using something newer like Node.js, you can still use this test by replacing `garbage.php` and `getIP.php`. If your server does not support PHP, or you're using something newer like Node.js, you can still use this test by replacing `garbage.php`, `empty.php` and `getIP.php` with equivalents.
### Replacements ### Replacements
@ -199,6 +199,9 @@ If you're using Node.js or some other server, your replacement should accept the
It is important here to turn off compression, and generate incompressible data. It is important here to turn off compression, and generate incompressible data.
A symlink to `/dev/urandom` is also ok. A symlink to `/dev/urandom` is also ok.
#### Replacement for `empty.php`
Your replacement must simply respond with a HTTP code 200 and send nothing else. You may want to send additional headers to disable caching.
#### Replacement for `getIP.php` #### Replacement for `getIP.php`
Your replacement must simply respond with the client's IP as plaintext. Nothing fancy. Your replacement must simply respond with the client's IP as plaintext. Nothing fancy.
@ -206,7 +209,7 @@ Your replacement must simply respond with the client's IP as plaintext. Nothing
You need to start the test with your replacements like this: You need to start the test with your replacements like this:
```js ```js
w.postMessage('start {"url_dl": "newGarbageURL", "url_getIp": "newIpURL"}') w.postMessage('start {"url_dl": "newGarbageURL", "url_ul": "newEmptyURL", "url_ping": "newEmptyURL", "url_getIp": "newIpURL"}')
``` ```

View file

6
empty.php Normal file
View file

@ -0,0 +1,6 @@
<?php
header( "HTTP/1.1 200 OK" );
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
?>

View file

@ -85,7 +85,7 @@
jitter.textContent = data[5] jitter.textContent = data[5]
ip.textContent = 'Your IP: ' + data[4] ip.textContent = 'Your IP: ' + data[4]
} }
w.postMessage('start {"url_dl": "garbage.php", "url_ul": "empty.dat", "url_ping": "empty.dat", "time_dl": "10", "time_ul": "15", "count_ping": "30"}') // start with custom parameters. paths are relative to js file. you can omit parameters that you don't want to change w.postMessage('start {"url_dl": "garbage.php", "url_ul": "empty.php", "url_ping": "empty.php", "time_dl": "10", "time_ul": "15", "count_ping": "30"}') // start with custom parameters. paths are relative to js file. you can omit parameters that you don't want to change
</script> </script>
</body> </body>
</html> </html>

View file

@ -85,7 +85,7 @@
document.getElementById('ip').textContent = 'Your IP: ' + data[4] document.getElementById('ip').textContent = 'Your IP: ' + data[4]
updateGauge(ggjitter, data[5]) updateGauge(ggjitter, data[5])
} }
w.postMessage('start {"time_ul": "10", "time_dl": "10", "count_ping": "50", "url_dl": "garbage.php", "url_ul": "empty.dat", "url_ping": "empty.dat", "url_getIp": "getIP.php"}') w.postMessage('start {"time_ul": "10", "time_dl": "10", "count_ping": "50", "url_dl": "garbage.php", "url_ul": "empty.php", "url_ping": "empty.php", "url_getIp": "getIP.php"}')
} }
function abortTest() { function abortTest() {
if (w) w.postMessage('abort') if (w) w.postMessage('abort')

View file

@ -1,5 +1,5 @@
/* /*
HTML5 Speedtest v4.1 HTML5 Speedtest v4.2.1
by Federico Dossena by Federico Dossena
https://github.com/adolfintel/speedtest/ https://github.com/adolfintel/speedtest/
GNU LGPLv3 License GNU LGPLv3 License
@ -19,8 +19,8 @@ var settings = {
time_dl: 15, // duration of download test in seconds time_dl: 15, // duration of download test in seconds
count_ping: 35, // number of pings to perform in ping test count_ping: 35, // number of pings to perform in ping test
url_dl: 'garbage.php', // path to a large file or garbage.php, used for download test. must be relative to this js file url_dl: 'garbage.php', // path to a large file or garbage.php, used for download test. must be relative to this js file
url_ul: 'empty.dat', // path to an empty file, used for upload test. must be relative to this js file url_ul: 'empty.php', // path to an empty file, used for upload test. must be relative to this js file
url_ping: 'empty.dat', // path to an empty file, used for ping test. must be relative to this js file url_ping: 'empty.php', // path to an empty file, used for ping test. must be relative to this js file
url_getIp: 'getIP.php', // path to getIP.php relative to this js file, or a similar thing that outputs the client's ip url_getIp: 'getIP.php', // path to getIP.php relative to this js file, or a similar thing that outputs the client's ip
xhr_dlMultistream: 10, // number of download streams to use (can be different if enable_quirks is active) xhr_dlMultistream: 10, // number of download streams to use (can be different if enable_quirks is active)
xhr_ulMultistream: 3, // number of upload streams to use (can be different if enable_quirks is active) xhr_ulMultistream: 3, // number of upload streams to use (can be different if enable_quirks is active)

File diff suppressed because one or more lines are too long