Commit Graph

84 Commits

Author SHA1 Message Date
Rob Wu
1308e34247 More test coverage for redirects 2016-02-26 16:10:53 +01:00
Rob Wu
35932a0ac1 Add tests for misbehaving servers + fix bug 2016-02-26 15:51:17 +01:00
Rob Wu
16b1a7e3a0 requireHeader: Improve coverage and fix bug
When the single-string version of requireHeader was used, it was not
properly transformed to a lowercase string. Now it is.
2016-02-26 13:13:58 +01:00
Rob Wu
24db52500f Remove requiresPort dependency
location.host is directly parsed from the full URL, so the
"concatenate host and port" branch was never taken.
2016-02-26 12:58:11 +01:00
Rob Wu
f9af03e762 Add Travis and test coverage
Notes:
- npm run test also runs the memory tests, which might be flaky on
  some systems.
- npm run test-coverage only runs the unit tests (it can't run the
  memory test anyway because the memory tests create a Node child
  process, and istanbul cannot cover that).
2016-02-26 12:38:59 +01:00
Rob Wu
0872577729 Enforce a consistent coding style using eslint 2016-02-26 12:31:35 +01:00
Rob Wu
e8f0e64168 Version 0.3.0
- Support proxying through proxy (`getProxyForUrl` option, defaulting to
  proxy configuration from the environment variables, see
  https://github.com/Rob--W/proxy-from-env) (#37).
- Update gTLD list.
2016-02-19 00:48:45 +01:00
Rob Wu
97b09d599d Update gTLD list 2016-02-19 00:47:39 +01:00
Rob Wu
bbe3378c35 Tests: Replace space with dash in header name
Node.js has forbidden header names with spaces in
6192c9892f.

The next error is thrown when the test sets the "some header" header:
Uncaught TypeError: Header name must be a valid HTTP Token ["some header"]

To fix it, replace spaces with dashes.
2016-02-19 00:39:17 +01:00
Rob Wu
8568c06b17 Support proxying through a proxy - #37
Automatically respects proxy headers from environment variables,
using https://github.com/Rob--W/proxy-from-env
2016-02-19 00:22:20 +01:00
Rob Wu
440d2de180 Version 0.2.5
- Add setHeaders to replace request headers with a fixed value (#33).
2015-08-23 14:48:29 +02:00
Rob Wu
a2f0c05b24 Add more tests for setHeaders 2015-08-23 10:58:58 +02:00
Rob Wu
015627b3f4 setHeaders is a dict, not an array 2015-08-23 10:52:01 +02:00
Nikolay Derkach
c5a3877e6c add setHeaders option 2015-08-22 16:49:59 -07:00
Rob Wu
8429bb3c58 Version 0.2.4
- Add originBlacklist (#32) and originWhitelist (#24) options.
- Update gTLD list.
2015-08-16 01:12:12 +02:00
Rob Wu
c0048573e9 Update gTLD list 2015-08-16 01:11:11 +02:00
Rob Wu
837dee582c Add originBlacklist + originWhitelist
- originWhitelist resolves #24
- originBlacklist may help with #32
2015-08-16 01:05:26 +02:00
Rob Wu
7a138b36cc Version 0.2.3
Changes:
- Updated to node-http-proxy 1.11.1 from 1.3.0
- Add httpsOptions configuration to listen as a https server.
- Update gTLD list, and allow requests to unlisted TLDs if the
  scheme is explicitly set (#14).
- Added loads of unit tests and automatic memory leak tests.
2015-05-09 11:26:23 +02:00
Rob Wu
f8f718ead8 Add tests for memory leaks
Using the performNRequests, I collected the following statistics
before choosing the maximum allowed "leaked" memory.

Node.js 0.12.2,
Using the http module ('use-http-instead-of-cors-anywhere'):

Memory usage delta: 132800 (100 requests of 50 kb each, 250ms)
Memory usage delta: 110144 (100 requests of 1 kb each, 172ms)
Memory usage delta: 709936 (1000 requests of 1 kb each, 902ms)
Memory usage delta: 865104 (10000 requests of 1 kb each, 7073ms)
Memory usage delta: 930416 (100000 requests of 1 kb each, 62856ms)

Using CORS Anywhere:

Memory usage delta: 356784 (100 requests of 50 kb each, 1004ms)
Memory usage delta: 355248 (100 requests of 1 kb each, 641ms)
Memory usage delta: 1326856 (1000 requests of 1 kb each, 3338ms)
Memory usage delta: 1462584 (10000 requests of 1 kb each, 21186ms)
Memory usage delta: 1473624 (100000 requests of 1 kb each, 211202ms)

Clearly, there is a small leak, but it is not proportional/linear
in terms of the number of requests, so the observed "leak" is probably
not an issue. Furthermore, the "leak" also occurs with the plain
http module.

After setting fixed limits, I ran the tests on Node.js 0.10.25 and
observed that the tests failed due to the too low limits, so I
incremented the limits (400 -> 550, 1500 -> 2000).
2015-05-09 11:23:27 +02:00
Rob Wu
0e594a2b03 Skip host check if scheme is explicitly set
Fixes https://github.com/Rob--W/cors-anywhere/issues/14

This allows CORS anywhere to be forwards-compatible with the surge
of new gTLDs.
2015-05-09 11:09:59 +02:00
Rob Wu
903f3d32dc Update TLD list. 2015-05-06 20:15:50 +02:00
Rob Wu
fbf3ce9255 Update copyright year to 2015 2015-05-06 20:15:50 +02:00
Rob Wu
19de080098 Move inline jshint directive to .jshintrc 2015-05-06 20:15:50 +02:00
Rob Wu
d437bc9225 Test that redirect headers are not set in response 2015-05-06 20:02:55 +02:00
Rob Wu
b5d601f823 Verify and update links to node-http-proxy 2015-05-06 19:53:57 +02:00
Rob Wu
024d540e7c Fix test expectations for xfwd 2015-05-06 19:46:58 +02:00
Rob Wu
2d84862546 Upgrade http-proxy to 1.11.1
All xfwd and tests fails with this change, but that's because the
tests themselves were incorrect (using port 80/443 instead of the
ephemeral ports created for the tests).
2015-05-06 19:19:21 +02:00
Rob Wu
f98705f27b Add test for proxy error 2015-05-06 18:40:04 +02:00
Rob Wu
e8202aa31f Add more xfwd tests (https+http & http+https) 2015-05-06 18:20:11 +02:00
Rob Wu
056cb446fe x-forwarded-port should match the request port.
Not the proxied one. These tests will now fail, but that's because
the current implementation is apparently incorrect.
2015-05-06 12:08:53 +02:00
Rob Wu
80da247827 Add httpsOptions option to create https.Server
Note: This does not work with the current version of node-http-proxy
and node 0.12.0 because req.connection.pair is not defined.
2015-05-06 12:07:31 +02:00
Rob Wu
1ee157fc0f Add unit tests 2015-05-05 22:37:20 +02:00
Rob Wu
f0bdb5ffd1 Remove manual leak test
webkit-devtools-agent (tested with 0.2.4 and 0.3.1) is incompatible with
Node 0.12.0. The manual test adds no value at this point, so it has been
removed, including the dependencies (webkit-devtools-agent).
2015-05-05 18:08:33 +02:00
Rob Wu
6b54191df9 0.2.2 - Expose every response header #12 2014-10-05 16:14:49 +02:00
Rob Wu
4343044781 Default to https for the CORS API.
Heroku uses Strict Transport Security (HSTS), which forces that all
requests to *.herokuapp.com must use HSTS. However. Chrome cannot read
the CORS response after a HSTS redirect due to https://crbug.com/387198.

Since the request is going to be redirected to https anyway, the demo
and the documentation will use https by default.
2014-08-29 19:17:52 +02:00
Rob Wu
0745b894c6 0.2.1 - Update URL parsing logic (fixes #9) 2014-08-29 16:30:50 +02:00
Rob Wu
c78854e4cf 0.2.0 - upgraded to node-http-proxy 1.3.0
Upgrading fixes the issue that the server crashes when the request
times out (ETIMEDOUT).
2014-08-27 20:16:46 +02:00
Rob Wu
90d81e7033 Update TLD list 2014-08-25 13:43:13 +02:00
Rob Wu
bd9af5849f Upgrade from http-proxy 0.10.x to 1.3.0 2014-08-25 13:39:25 +02:00
Rob Wu
beadd3fe77 v0.1.9 - Always use Access-Control-Allow-Origin: *
Fixes #6
2014-03-12 18:18:08 +01:00
Rob Wu
7983d1e7ae Update dev dependency
To test for mem leaks, just run node test/runner.js
and follow the instructions.
2014-01-03 14:21:49 +01:00
Rob Wu
88797acc38 Version 0.1.8 2013-10-19 14:42:22 +02:00
Rob Wu
a322df91c4 Header checks after error checks
With this commit, you will see the following messages instead of
"Missing required request header ...":

 /iscorsneeded = no with direct browsing
 /favicon.ico = 404 not found
2013-09-10 23:10:14 +02:00
Rob Wu
4b308db027 Corrected typo in README
Consequence of error:
- Requests to the CORS anywhere API are prefixed as well, i.e.
  https://cors-anywhere.herokuapp.com/ ->
  https://cors-anywhere.herokuapp.com/https://cors-anywhere.herokuapp.com/

Impact of error:
- Minimal. The functionality of the API is not affected.
2013-09-03 18:08:00 +02:00
Rob Wu
8caf221cc2 Version 0.1.7 2013-08-30 11:43:11 +02:00
Rob Wu
d2023b45e1 Fix POST -> GET conversion on redirect 2013-08-30 11:42:51 +02:00
Rob Wu
a784fc96f8 Simplified demo.html; show proxyError on error 2013-08-29 19:20:40 +02:00
Rob Wu
cd97423db9 Fix memory leak 2013-08-29 15:17:19 +02:00
Rob Wu
b76d6457f0 Add some tests (mainly interested in memleak test)
If you wish to check if the API works, launch demo.html,
set the global cors_api_url variable to your local instance,
enter an URL and press "GET" or "POST".
2013-08-29 14:25:20 +02:00
Rob Wu
a56fb8843c Add X-Final-URL 2013-08-29 10:12:03 +02:00