Skip to content

Commit

Permalink
Fixed a problem with upload and ping test with nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
adolfintel committed May 15, 2017
1 parent 65be39f commit ec61c14
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 16 deletions.
2 changes: 0 additions & 2 deletions .gitignore

This file was deleted.

19 changes: 11 additions & 8 deletions doc.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# HTML5 Speedtest

> 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/)

Expand Down Expand Up @@ -31,7 +31,7 @@ To install the test on your server, upload the following files:
* `speedtest_worker.min.js`
* `garbage.php`
* `getIP.php`
* `empty.dat`
* `empty.php`

You may also want to upload one of the examples to test it.
Later we'll see how to use the test without PHP.
Expand Down Expand Up @@ -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
* Default: `garbage.php`
* __Important:__ path is relative to js file
* __url_ul__: path to ab empty file or empty.dat to use for the upload test
* Default: `empty.dat`
* __url_ul__: path to ab empty file or empty.php to use for the upload test
* Default: `empty.php`
* __Important:__ path is relative to js file
* __url_ping__: path to an empty file or empty.dat to use for the ping test
* Default: `empty.dat`
* __url_ping__: path to an empty file or empty.php to use for the ping test
* Default: `empty.php`
* __Important:__ path is relative to js file
* __url_getIp__: path to getIP.php or replacement
* Default: `getIP.php`
Expand Down Expand Up @@ -186,7 +186,7 @@ __Important:__ do not simply kill the worker while it's running, as it will leav


## 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

Expand All @@ -199,14 +199,17 @@ 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.
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`
Your replacement must simply respond with the client's IP as plaintext. Nothing fancy.

### JS
You need to start the test with your replacements like this:

```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"}')
```


Expand Down
Empty file removed empty.dat
Empty file.
6 changes: 6 additions & 0 deletions empty.php
Original file line number Diff line number Diff line change
@@ -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");
?>
2 changes: 1 addition & 1 deletion example2.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ <h1>Speedtest</h1>
jitter.textContent = data[5]
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>
</body>
</html>
2 changes: 1 addition & 1 deletion example4.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
document.getElementById('ip').textContent = 'Your IP: ' + data[4]
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() {
if (w) w.postMessage('abort')
Expand Down
6 changes: 3 additions & 3 deletions speedtest_worker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
HTML5 Speedtest v4.1
HTML5 Speedtest v4.2.1
by Federico Dossena
https://github.com/adolfintel/speedtest/
GNU LGPLv3 License
Expand All @@ -19,8 +19,8 @@ var settings = {
time_dl: 15, // duration of download test in seconds
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_ul: 'empty.dat', // 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_ul: 'empty.php', // path to an empty file, used for upload 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
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)
Expand Down
2 changes: 1 addition & 1 deletion speedtest_worker.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ec61c14

Please sign in to comment.