grenache-nodejs-http 0.7.10 → 0.7.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -80,7 +80,9 @@ class TransportRPCClient extends Base.TransportRPCClient {
|
|
|
80
80
|
this.post({
|
|
81
81
|
timeout: req.opts.timeout,
|
|
82
82
|
body: postData,
|
|
83
|
-
|
|
83
|
+
headers: {
|
|
84
|
+
'grc-compress': isCompress ? 'gzip' : 'none'
|
|
85
|
+
},
|
|
84
86
|
encoding: null
|
|
85
87
|
}, async (err, body) => {
|
|
86
88
|
if (err) {
|
|
@@ -39,7 +39,7 @@ class TransportRPCServer extends Base.TransportRPCServer {
|
|
|
39
39
|
|
|
40
40
|
socket.on('request', (req, rep) => {
|
|
41
41
|
const isStream = req.headers['transfer-encoding'] === 'chunked'
|
|
42
|
-
const enc = req.headers['
|
|
42
|
+
const enc = req.headers['grc-compress'] || ''
|
|
43
43
|
const isCompress = enc.includes('gzip')
|
|
44
44
|
|
|
45
45
|
const cert = secure ? req.socket.getPeerCertificate() : undefined
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "grenache-nodejs-http",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.13",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Granache Node.js HTTP implementation",
|
|
6
6
|
"author": "prdn <paolo@bitfinex.com> (https://bitfinex.com/)",
|
|
@@ -11,17 +11,17 @@
|
|
|
11
11
|
"micro-services"
|
|
12
12
|
],
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"async": "^3.2.
|
|
15
|
-
"grenache-nodejs-base": "^0.7.
|
|
16
|
-
"grenache-nodejs-link": "^0.7.
|
|
17
|
-
"lodash": "^4.17.
|
|
18
|
-
"request": "^2.88.
|
|
14
|
+
"async": "^3.2.4",
|
|
15
|
+
"grenache-nodejs-base": "^0.7.5",
|
|
16
|
+
"grenache-nodejs-link": "^0.7.13",
|
|
17
|
+
"lodash": "^4.17.21",
|
|
18
|
+
"request": "^2.88.0"
|
|
19
19
|
},
|
|
20
20
|
"main": "index.js",
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"grenache-grape": "^0.9.
|
|
23
|
-
"mocha": "^
|
|
24
|
-
"standard": "^
|
|
22
|
+
"grenache-grape": "^0.9.12",
|
|
23
|
+
"mocha": "^10.2.0",
|
|
24
|
+
"standard": "^17.0.0"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"test": "npm run lint",
|
|
@@ -83,6 +83,29 @@ describe('RPC integration', () => {
|
|
|
83
83
|
})
|
|
84
84
|
}).timeout(7000)
|
|
85
85
|
|
|
86
|
+
it('buffered parsing works, compressed strings', (done) => {
|
|
87
|
+
serviceBuf.on('request', (rid, key, payload, handler, cert, meta) => {
|
|
88
|
+
assert.ok(typeof rid === 'string')
|
|
89
|
+
assert.strictEqual(key, 'rpc_buf')
|
|
90
|
+
assert.strictEqual(payload, 'hello')
|
|
91
|
+
|
|
92
|
+
assert.strictEqual(meta.isStream, false)
|
|
93
|
+
assert.strictEqual(meta.compress, true)
|
|
94
|
+
|
|
95
|
+
handler.reply(null, 'world')
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
const opts = { timeout: 100000, compress: true }
|
|
99
|
+
peer.request('rpc_buf', 'hello', opts, (err, result) => {
|
|
100
|
+
if (err) throw err
|
|
101
|
+
|
|
102
|
+
assert.strictEqual(result, 'world')
|
|
103
|
+
|
|
104
|
+
stop()
|
|
105
|
+
done()
|
|
106
|
+
})
|
|
107
|
+
}).timeout(7000)
|
|
108
|
+
|
|
86
109
|
it('buffered parsing works, strings from streaming client', (done) => {
|
|
87
110
|
serviceBuf.on('request', (rid, key, payload, handler, cert, meta) => {
|
|
88
111
|
assert.ok(typeof rid === 'string')
|