webpagetest
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -280,2 +280,32 @@ /** | ||
}, | ||
'htmlbody': { | ||
name: 'htmlBody', | ||
api: 'htmlbody', | ||
bool: true, | ||
info: 'save the content of only the base HTML response' | ||
}, | ||
'continuous': { | ||
name: 'continuousVideoCapture', | ||
api: 'continuousVideo', | ||
bool: true, | ||
info: 'capture video continuously (unstable/experimental, may cause tests to fail)' | ||
}, | ||
'clearcerts': { | ||
name: 'clearCerts', | ||
api: 'clearcerts', | ||
bool: true, | ||
info: 'clear the OS certificate caches (causes IE to do OCSP/CRL checks during SSL negotiation if the certificates are not already cached)' | ||
}, | ||
'medianvideo': { | ||
name: 'medianVideo', | ||
api: 'mv', | ||
bool: true, | ||
info: 'store the video from the median run when capturing video is enabled' | ||
}, | ||
'tsview': { | ||
name: 'tsView', | ||
api: 'tsview_id', | ||
param: 'id', | ||
info: 'test name to use when submitting results to tsviewdb (for private instances that have integrated with tsviewdb)' | ||
}, | ||
'mobile': { | ||
@@ -330,2 +360,14 @@ name: 'emulateMobile', | ||
}, | ||
'datareduction': { | ||
name: 'dataReduction', | ||
api: 'dataReduction', | ||
bool: true, | ||
info: 'enable data reduction on Chrome 34+ Android (Chrome only)' | ||
}, | ||
'useragent': { | ||
name: 'userAgent', | ||
api: 'uastring', | ||
param: 'string', | ||
info: 'custom user agent string (Chrome only)' | ||
}, | ||
'cmdline': { | ||
@@ -337,14 +379,2 @@ name: 'commandLine', | ||
}, | ||
'htmlbody': { | ||
name: 'htmlBody', | ||
api: 'htmlbody', | ||
bool: true, | ||
info: 'save the content of only the base HTML response' | ||
}, | ||
'continuous': { | ||
name: 'continuousVideoCapture', | ||
api: 'continuousVideo', | ||
bool: true, | ||
info: 'capture video continuously (unstable/experimental, may cause tests to fail)' | ||
}, | ||
'poll': { | ||
@@ -571,2 +601,16 @@ name: 'pollResults', | ||
} | ||
}, | ||
'listen': { | ||
'key': { | ||
name: 'key', | ||
key: 'k', | ||
param: 'file', | ||
info: 'private key file to use for SSL' | ||
}, | ||
'cert': { | ||
name: 'cert', | ||
key: 'c', | ||
param: 'file', | ||
info: 'public x509 certificate file to use for SSL' | ||
} | ||
} | ||
@@ -702,3 +746,4 @@ }; | ||
optional: true, | ||
info: 'start webpagetest-api server on <hostname>:<port> [hostname:%s]' | ||
options: [options.listen], | ||
info: 'start webpagetest-api proxy server on <hostname>:<port> [hostname:%s]' | ||
} | ||
@@ -738,3 +783,3 @@ }; | ||
if (options[key].bool) { | ||
opts[options[key].name] = !reBool.test(query[key]) | ||
opts[options[key].name] = !reBool.test(query[key]); | ||
} else if (!valid || (valid && valid.test(query[key]))) { | ||
@@ -741,0 +786,0 @@ opts[options[key].name] = decodeURIComponent(query[key]); |
@@ -8,5 +8,7 @@ /** | ||
var http = require('http'), | ||
var https = require('https'), | ||
http = require('http'), | ||
path = require('path'), | ||
url = require('url'), | ||
fs = require('fs'), | ||
mapping = require('./mapping'); | ||
@@ -146,29 +148,38 @@ | ||
module.exports = { | ||
listen: function listen(local, callback) { | ||
var httpServer = http.createServer(route.bind(this)); | ||
listen: function listen(local, options, callback) { | ||
var server; | ||
httpServer.on('error', function listenError(err) { | ||
if (typeof callback === 'function') { | ||
callback(err); | ||
} | ||
}).on('listening', function listenError() { | ||
if (typeof callback === 'function') { | ||
callback(undefined, { | ||
server: httpServer, | ||
protocol: 'http', | ||
if (fs.existsSync(options.key) && fs.existsSync(options.cert)) { | ||
server = https.createServer({ | ||
key: fs.readFileSync(path.resolve(process.cwd(), options.key)), | ||
cert: fs.readFileSync(path.resolve(process.cwd(), options.cert)) | ||
}, route.bind(this)); | ||
} else { | ||
server = http.createServer(route.bind(this)); | ||
} | ||
server.on('error', function listenError(err) { | ||
if (typeof callback === 'function') { | ||
callback(err); | ||
} | ||
}).on('listening', function listenError() { | ||
if (typeof callback === 'function') { | ||
callback(undefined, { | ||
server: server, | ||
protocol: server instanceof https.Server ? 'https' : 'http', | ||
hostname: local.hostname, | ||
port: local.port, | ||
url: url.format({ | ||
protocol: server instanceof https.Server ? 'https' : 'http', | ||
hostname: local.hostname, | ||
port: local.port, | ||
url: url.format({ | ||
protocol: 'http', | ||
hostname: local.hostname, | ||
port: local.port | ||
}) | ||
}); | ||
} | ||
}).listen(local.port); | ||
port: local.port | ||
}) | ||
}); | ||
} | ||
}).listen(local.port); | ||
buildHelp(url.format(this.config.hostname)); | ||
return httpServer; | ||
return server; | ||
} | ||
}; |
@@ -151,3 +151,3 @@ /** | ||
pathname = url.format({ | ||
pathname: path.join(config.pathname, pathname), | ||
pathname: url.resolve(config.pathname, pathname), | ||
query: query | ||
@@ -648,6 +648,8 @@ }); | ||
function listen(local, callback) { | ||
function listen(local, options, callback) { | ||
callback = callback || options; | ||
options = options === callback ? {} : options; | ||
local = helper.localhost(local, WebPageTest.defaultListenPort); | ||
return server.listen.call(this, local, callback); | ||
return server.listen.call(this, local, options, callback); | ||
} | ||
@@ -654,0 +656,0 @@ |
{ | ||
"name": "webpagetest", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "WebPageTest API wrapper for NodeJS", | ||
@@ -5,0 +5,0 @@ "author": "Marcel Duran <github@marcelduran.com> (http://github.com/marcelduran)", |
@@ -61,3 +61,3 @@ ## WebPageTest API Wrapper for NodeJS [![Build Status](https://secure.travis-ci.org/marcelduran/webpagetest-api.png?branch=master)](http://travis-ci.org/marcelduran/webpagetest-api) [![Dependencies Status](https://david-dm.org/marcelduran/webpagetest-api.png)](https://david-dm.org/marcelduran/webpagetest-api) | ||
* **player _\<id\>_: get a html5 player for a video _\<id\>_ | ||
* **listen** _[port]_: start webpagetest-api server on port _[7791_] | ||
* **listen** _[options]_ _[port]_: start webpagetest-api server on port _[7791_] | ||
* **batch** _\<file\>_: run commands in batch, i.e. one command per line from _\<file\>_ in parallel | ||
@@ -111,2 +111,7 @@ | ||
* **-Z, --spof** _\<domains\>_: space-delimited list of domains to simulate failure by re-routing to blackhole.webpagetest.org to silently drop all requests | ||
* **--htmlbody**: save the content of only the base HTML response | ||
* **--continuous**: capture video continuously (unstable/experimental, may cause tests to fail) | ||
* **--clearcerts**: clear the OS certificate caches (causes IE to do OCSP/CRL checks during SSL negotiation if the certificates are not already cached) | ||
* **--medianvideo**: store the video from the median run when capturing video is enabled | ||
* **--tsview** _\<id\>_: test name to use when submitting results to tsviewdb (for private instances that have integrated with tsviewdb) | ||
* **-W, --mobile**: (experimental) emulate mobile browser: Chrome mobile user agent, 640x960 screen, 2x scaling and fixed viewport (Chrome only) | ||
@@ -119,5 +124,5 @@ * **-M, --timeline**: capture Developer Tools Timeline (Chrome only) | ||
* **-q, --spdynossl**: use SPDY without SSL (Chrome only) | ||
* **--datareduction**: enable data reduction on Chrome 34+ Android (Chrome only) | ||
* **--useragent** _\<string\>_: custom user agent string (Chrome only) | ||
* **--cmdline** _\<switches\>_: use a list of custom command line switches (Chrome only) | ||
* **--htmlbody**: save the content of only the base HTML response | ||
* **--continuous**: capture video continuously (unstable/experimental, may cause tests to fail) | ||
* **--poll** _[interval]_: poll for results after test is scheduled at every \<interva\l> seconds [5] | ||
@@ -172,2 +177,7 @@ * **--wait** _[hostname:port]_: wait for test results informed by agent once complete listening on \<hostname\>:\<port\> [hostname:first port available above 8000] | ||
#### Listen (works for **listen** command only) | ||
* **-k, --key** _\<file\>_: private key file to use for SSL | ||
* **-c, --cert** _\<file\>_: public x509 certificate file to use for SSL | ||
### Examples | ||
@@ -342,3 +352,3 @@ #### 1. Get available locations | ||
* `getEmbedVideoPlayer(id, options, callback)` | ||
* `listen(port, callback)` | ||
* `listen(port, options, callback)` | ||
* `scriptToString(script)` | ||
@@ -426,2 +436,7 @@ | ||
* **spof**: _[String]_, array of string of domains to simulate failure by re-routing to blackhole.webpagetest.org to silently drop all requests | ||
* **htmlBody**: _Boolean_, save the content of only the base HTML response | ||
* **continuous**: _Boolean_, capture video continuously (unstable/experimental, may cause tests to fail) | ||
* **clearCerts**: _Boolean_, clear the OS certificate caches (causes IE to do OCSP/CRL checks during SSL negotiation if the certificates are not already cached) | ||
* **medianVideo**: _Boolean_, store the video from the median run when capturing video is enabled | ||
* **tsView**: _String_, test name to use when submitting results to tsviewdb (for private instances that have integrated with tsviewdb) | ||
* **emulateMobile**: _Boolean_, (experimental) emulate mobile browser: Chrome mobile user agent, 640x960 screen, 2x scaling and fixed viewport (Chrome only) | ||
@@ -434,2 +449,4 @@ * **timeline**: _Boolean_, capture Developer Tools Timeline (Chrome only) | ||
* **spdyNoSSL**: _Boolean_, use SPDY without SSL (Chrome only) | ||
* **dataReduction**: _Boolean_, enable data reduction on Chrome 34+ Android (Chrome only) | ||
* **userAgent**: _String_, custom user agent string (Chrome only) | ||
* **commandLine**: _[String]_, use a list of custom command line switches (Chrome only) | ||
@@ -485,2 +502,6 @@ * **pollResults**: _Number_, poll for results after test is scheduled at every <interval> seconds [5] | ||
#### Listen (works for `listen` method only) | ||
* **key** _String_: private key file path to use for SSL | ||
* **cert** _String_: public x509 certificate file path to use for SSL | ||
### Examples | ||
@@ -567,2 +588,9 @@ | ||
``` | ||
```bash | ||
$ webpagetest listen 8443 --key key.pem --cert cert.pem --server wpt.foo.com | ||
``` | ||
```bash | ||
server listening on port 8443 | ||
https://localhost:8443 | ||
``` | ||
@@ -572,2 +600,3 @@ #### Notes | ||
* `wpt.foo.com` is overriding the default `www.webpagetest.org` server but can still be overridden with `server` option | ||
* when _--key_ and _--cert_ are provided, HTTPS is used instead of default HTTP server | ||
@@ -646,2 +675,3 @@ ### Module | ||
* 0.2.4: Added test options: clearcerts, medianvideo, datareduction, useragent and tsview; HTTPS support to listen/proxy server | ||
* 0.2.3: Updated DevTools Timeline API url endpoint for timeline command | ||
@@ -648,0 +678,0 @@ * 0.2.2: Added response body command/method |
@@ -6,3 +6,5 @@ | ||
-h, --help output usage information | ||
-h, --help output usage information | ||
-k, --key <file> private key file to use for SSL | ||
-c, --cert <file> public x509 certificate file to use for SSL | ||
@@ -44,2 +44,7 @@ | ||
-Z, --spof <domains> space-delimited list of domains to simulate failure by re-routing to blackhole.webpagetest.org to silently drop all requests | ||
--htmlbody save the content of only the base HTML response | ||
--continuous capture video continuously (unstable/experimental, may cause tests to fail) | ||
--clearcerts clear the OS certificate caches (causes IE to do OCSP/CRL checks during SSL negotiation if the certificates are not already cached) | ||
--medianvideo store the video from the median run when capturing video is enabled | ||
--tsview <id> test name to use when submitting results to tsviewdb (for private instances that have integrated with tsviewdb) | ||
-W, --mobile (experimental) emulate mobile browser: Chrome mobile user agent, 640x960 screen, 2x scaling and fixed viewport (Chrome only) | ||
@@ -52,5 +57,5 @@ -M, --timeline capture Developer Tools Timeline (Chrome only) | ||
-q, --spdynossl use SPDY without SSL (Chrome only) | ||
--datareduction enable data reduction on Chrome 34+ Android (Chrome only) | ||
--useragent <string> custom user agent string (Chrome only) | ||
--cmdline <switches> use a list of custom command line switches (Chrome only) | ||
--htmlbody save the content of only the base HTML response | ||
--continuous capture video continuously (unstable/experimental, may cause tests to fail) | ||
--poll [interval] poll for results after test is scheduled at every <interval> seconds [5] | ||
@@ -57,0 +62,0 @@ --wait [hostname:port] wait for test results informed by agent once complete listening on <hostname>:<port> [hostname:first port available above 8000] |
@@ -27,3 +27,3 @@ | ||
player <id> get a html5 player for a video <id> | ||
listen [hostname:port] start webpagetest-api server on <hostname>:<port> [hostname:7791] | ||
listen [options] [hostname:port] start webpagetest-api proxy server on <hostname>:<port> [hostname:7791] | ||
batch <file> run commands in batch, i.e. one command per line from <file> in parallel | ||
@@ -30,0 +30,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24161483
53747
700
4
8