kaazing / http2-cache.js

2 stars 11 forks source link

Features/config worker support and xhr channel support #89

Open hthetiot opened 6 years ago

hthetiot commented 6 years ago

Todo

Usage:

XMLHttpRequest.proxy({
        'transport': 'ws://localhost:7081/path',
        'worker': true, // bool to enable, string 'path to worker' or Worker instance
       // OR
        'worker': 'packages/http2-cache/dist/http2-cache.js'
        'proxy': [
            'http://cache-endpoint/',
            'http://localhost:7080/path/proxy',
        ]
    });

Test result

screen shot 2017-12-15 at 2 20 07 pm

Reviewer note

Main commit is ece50afdab0170a83dd7629eedbcd8de01bc15e5 Previous commit to this one are in #88

configuration init worker handler

https://github.com/kaazing/http2-cache.js/blob/features/workerSupport/lib/configuration.js#L53

addConfig handler

https://github.com/kaazing/http2-cache.js/blob/features/workerSupport/lib/configuration.js#L339

sendViaChannel handler

https://github.com/kaazing/http2-cache.js/blob/features/workerSupport/lib/xhr.js#L413 https://github.com/kaazing/http2-cache.js/blob/features/workerSupport/lib/configuration.js#L459

Browser Support

Tested: Chrome, Firefox, Opera, Safari, IE.

Tests results

Test:

With gzip

screen shot 2018-02-06 at 12 21 11 pm

npm run integration:worker

screen shot 2017-12-18 at 1 56 39 pm screen shot 2017-12-18 at 1 57 13 pm screen shot 2018-02-06 at 3 06 02 pm screen shot 2017-12-18 at 1 58 24 pm
dpwspoon commented 6 years ago

This PR includes dist/ files. Please remove these. Follow up question, should the latest released dist/ file from the last release be on the develop branch? I would lean towards no, but I'm ok with it if that is better...

hthetiot commented 6 years ago

@dpwspoon Done

hthetiot commented 6 years ago

Need to fix failing test

Uncaught Failed to read the 'responseText' property from 'XMLHttpRequest': The value is only accessible if the object's 'responseType' is '' or 'text' (was 'json')

hthetiot commented 6 years ago

Need to fix karma tests

dpwspoon commented 6 years ago

@hthetiot Please change it to run in the worker by default (or confirm that it already does)

dpwspoon commented 6 years ago

Please see travis failures.

dpwspoon commented 6 years ago

We should consider piping/post-messaging the logging over into the main tab.

hthetiot commented 6 years ago

Note about gzip xhr support:

hthetiot commented 6 years ago

@jitsni Need to check with you for the possible related issue with encoding on http2.js

hthetiot commented 6 years ago

https://github.com/curl/curl/issues/661#issuecomment-184903489

hthetiot commented 6 years ago

Still having issues with gzip test-server using websocket + http2

hthetiot commented 6 years ago

@johnnykahalawai Merged with last http2-cache.js changes from develop.

@tejaede For testing you can use:

Note: Worker and ArrayBuffer enabled by default or can be disabled with this:

XMLHttpRequest.configuration.useTransferable = false;
XMLHttpRequest.configuration.useWorker = false;

More Example: https://github.com/kaazing/http2-cache.js/blob/features/workerSupport/integration-test/http2-worker-itest.js#L342

cc @dpwspoon

dpwspoon commented 5 years ago

LGTM