Comparing version 2.2.0 to 2.3.0
@@ -6,3 +6,3 @@ 'use strict' | ||
const parseMs = require('ms') | ||
const deepSet = require('deep-set') | ||
const deepSet = require('dset') | ||
const herr = require('http-errors') | ||
@@ -21,2 +21,3 @@ const http = require('http') | ||
const URL = require('url').URL | ||
const hasOwnProperty = Object.prototype.hasOwnProperty | ||
@@ -32,2 +33,3 @@ module.exports = class Client extends EventEmitter { | ||
this.protocol = opts.protocol || 'http:' | ||
this.headers = opts.headers || null | ||
@@ -60,3 +62,3 @@ if (!Number.isInteger(this.port) || this.port <= 0) { | ||
const headers = opts.headers || (opts.headers = {}) | ||
const headers = {} | ||
const catalog = opts.catalog || this.catalog | ||
@@ -69,9 +71,9 @@ const schema = opts.schema || this.schema | ||
// TODO: these may not be necessary for GET /v1/statement/{queryId}/{token} | ||
if (catalog) headers['X-Presto-Catalog'] = catalog | ||
if (schema) headers['X-Presto-Schema'] = schema | ||
if (timezone) headers['X-Presto-Time-Zone'] = timezone | ||
if (parametricDatetime) headers['X-Presto-Client-Capabilities'] = 'PARAMETRIC_DATETIME' | ||
if (catalog) headers['x-presto-catalog'] = catalog | ||
if (schema) headers['x-presto-schema'] = schema | ||
if (timezone) headers['x-presto-time-zone'] = timezone | ||
if (parametricDatetime) headers['x-presto-client-capabilities'] = 'PARAMETRIC_DATETIME' | ||
if (user) headers['X-Presto-User'] = user | ||
if (opts.json) headers['Accept'] = 'application/json' | ||
if (user) headers['x-presto-user'] = user | ||
if (opts.json) headers['accept'] = 'application/json' | ||
@@ -85,12 +87,22 @@ // TODO: move outside this function, only add on initial statement request. | ||
const pairs = Array.from(this._session.values()) | ||
headers['X-Presto-Session'] = pairs.join(',') | ||
} else if ('X-Presto-Session' in headers) { | ||
delete headers['X-Presto-Session'] | ||
headers['x-presto-session'] = pairs.join(',') | ||
} | ||
headers['X-Presto-Source'] = this.source | ||
headers['User-Agent'] = this.userAgent | ||
headers['Connection'] = 'keep-alive' | ||
headers['Accept-Encoding'] = 'gzip, deflate, identity' | ||
headers['x-presto-source'] = this.source | ||
headers['user-agent'] = this.userAgent | ||
headers['connection'] = 'keep-alive' | ||
headers['accept-encoding'] = 'gzip, deflate, identity' | ||
for (const src of [this.headers, opts.headers]) { | ||
if (src == null) continue | ||
for (const k in src) { | ||
if (!hasOwnProperty.call(src, k)) continue | ||
if (/^x-presto-session$/i.test(k) && opts.method !== 'POST') continue | ||
headers[k.toLowerCase()] = src[k] | ||
} | ||
} | ||
opts.headers = headers | ||
this._makeRequest(opts, new Backoff({ min: 1e3, max: 10e3 }), callback) | ||
@@ -308,4 +320,4 @@ } | ||
} else if (type === 'integer') { | ||
value = parseInt(value, 10) | ||
def = parseInt(def, 10) | ||
value = value === '' ? null : parseInt(value, 10) | ||
def = def === '' ? null : parseInt(def, 10) | ||
} | ||
@@ -427,3 +439,3 @@ | ||
function retryable (err) { | ||
return err.code === 'ECONNREFUSED' || err.statusCode === 503 | ||
return err.code === 'ECONNREFUSED' || err.code === 'ECONNRESET' || err.statusCode === 503 | ||
} | ||
@@ -430,0 +442,0 @@ |
@@ -34,2 +34,3 @@ 'use strict' | ||
this._deserialize = opts.deserialize !== false | ||
this._headers = opts.headers | ||
@@ -61,2 +62,3 @@ this._reset(false) | ||
body: this._sql, | ||
headers: this._headers, | ||
json: true, | ||
@@ -232,2 +234,3 @@ expectStatusCode: 200 | ||
method: 'GET', | ||
headers: this._headers, | ||
json: true, | ||
@@ -234,0 +237,0 @@ expectStatusCode: 200 |
{ | ||
"name": "lento", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "Streaming client for Presto HTTP protocol v1", | ||
@@ -24,3 +24,3 @@ "license": "MIT", | ||
"debug": "^4.1.0", | ||
"deep-set": "^1.0.1", | ||
"dset": "^2.0.1", | ||
"http-errors": "^1.8.0", | ||
@@ -37,3 +37,3 @@ "ms": "^2.1.1", | ||
"npm-run-all": "^4.1.5", | ||
"standard": "^14.3.4", | ||
"standard": "^16.0.3", | ||
"tape": "^5.0.1" | ||
@@ -40,0 +40,0 @@ }, |
@@ -88,2 +88,3 @@ # lento <sup id="a1">[1](#f1)</sup> | ||
- `timezone`: string, for example `UTC`, default none. Sent as `X-Presto-Time-Zone` header. | ||
- `headers`: object containing custom headers to set on every request such as `Authorization` (case-insensitive). Headers specified here take precedence over other options that set headers. | ||
- `parametricDatetime`: boolean, default false. Opt-in to datetime types with variable precision, for example `timestamp(6)`. When not set, datetime types are returned with a precision of 3. | ||
@@ -126,4 +127,5 @@ | ||
- `highWaterMark`: number, default 0 | ||
- `rowFormat`: string, one of `object` (default) or `array`. | ||
- `rowFormat`: string, one of `object` (default) or `array` | ||
- `deserialize`: boolean, default true | ||
- `headers`: custom request headers. Merged with headers that were set in the constructor, if any. | ||
@@ -161,3 +163,5 @@ The `pageSize` specifies the maximum number of rows per page. Presto may return less per page. If Presto returns more rows than `pageSize`, the surplus is buffered and the stream will not make another HTTP request to Presto until fully drained. Note that if the (remainder of) rows fit in Presto's buffers, Presto will not block (until another HTTP request is made) but instead go into the `FINISHED` state after which you have 15 minutes (by default) to fetch the remaining results. If `pageSize` is <= 0 the stream emits pages as returned by Presto, without slicing them up. | ||
- `highWaterMark`: number, default 16 | ||
- `rowFormat`: string, one of `object` (default) or `array`. | ||
- `rowFormat`: string, one of `object` (default) or `array` | ||
- `deserialize`: boolean, default true | ||
- `headers`: custom request headers. Merged with headers that were set in the constructor, if any. | ||
@@ -164,0 +168,0 @@ <a name="query"></a> |
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
38519
638
296
+ Addeddset@^2.0.1
+ Addeddset@2.1.0(transitive)
- Removeddeep-set@^1.0.1
- Removeddeep-set@1.0.1(transitive)