Repository navigation
fix(kernel): honor a custom port over HTTPS on the kernel backend #636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d2e2169
97d67cb
a4c91da
9b2e94d
468af3a
23ffcf6
195a115
2fa5c5e
c8dc980
f4eef33
110acaf
fbffc2f
69855ec
3be0d05
2e9227d
1962201
09cb0e8
bbc4d01
2ac73f9
ed827f4
c5a0855
73a84a1
5fcc5b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| 5c3a909771f749174567af074bfe18c24a335f5c | ||
| 3b691d2a2c235ef847d61b308c31604979830994 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -269,12 +269,21 @@ export interface KernelFederationOptions { | |
| identityFederationClientId?: string; | ||
| } | ||
|
|
||
| /** | ||
| * Connection port forwarded as is to the napi binding's `ConnectionOptions.port`. | ||
| * The kernel validates it and folds it into the host. | ||
| */ | ||
| export interface KernelPortOptions { | ||
| port?: number; | ||
| } | ||
|
|
||
| export type KernelNativeConnectionOptions = KernelSessionDefaults & | ||
| KernelTlsOptions & | ||
| KernelHttpOptions & | ||
| KernelTelemetryOptions & | ||
| KernelProxyOptions & | ||
| KernelFederationOptions & | ||
| KernelPortOptions & | ||
| ( | ||
| | { | ||
| hostName: string; | ||
|
|
@@ -830,20 +839,13 @@ export function buildKernelProxyOptions(options: ConnectionOptions): KernelProxy | |
| return { proxy: out }; | ||
| } | ||
|
|
||
| // The kernel prepends `https://` to a bare host but keeps an explicit scheme. | ||
| // It otherwise ignores `port`, so carry it into the URL unless `host` already has one. | ||
| // The host is passed through as given. The kernel owns port folding, IPv6 bracketing, | ||
| // userinfo and path checks, and trailing-slash handling, and it prepends `https://` to a | ||
| // bare host. The one rewrite left here is plain HTTP: `https: false` sends an explicit | ||
| // `http://` scheme, and the kernel's scheme-based default port then applies. | ||
| function buildKernelHostName(options: ConnectionOptions): string { | ||
| if (options.https !== false) { | ||
| return options.host; | ||
| } | ||
| // The kernel accepts a full URL in `host`, so drop an existing `http://` or | ||
| // `https://` scheme before applying HTTP (`https: false` selects the scheme). | ||
| // Then strip a trailing `/` like the Thrift URL builder does. | ||
| const host = options.host.replace(/^https?:\/\//i, '').replace(/\/$/, ''); | ||
| // `name:port` or `[ipv6]:port`; a bare IPv6 literal like `::1` has no port. | ||
| const hasPort = /^(\[[^\]]+\]|[^:]+):\d+$/.test(host); | ||
| const port = options.port && !hasPort ? `:${options.port}` : ''; | ||
| return `http://${host}${port}`; | ||
| if (options.https !== false) return options.host; | ||
| return `http://${options.host.replace(/^https?:\/\//i, '')}`; | ||
|
cathleeny marked this conversation as resolved.
Resolved
cathleeny marked this conversation as resolved.
Resolved
cathleeny marked this conversation as resolved.
Resolved
cathleeny marked this conversation as resolved.
Resolved
|
||
| } | ||
|
cathleeny marked this conversation as resolved.
Resolved
|
||
|
|
||
| export function buildKernelConnectionOptions(options: ConnectionOptions): KernelNativeConnectionOptions { | ||
|
|
@@ -858,7 +860,8 @@ export function buildKernelConnectionOptions(options: ConnectionOptions): Kernel | |
| } & KernelTlsOptions & | ||
| KernelHttpOptions & | ||
| KernelProxyOptions & | ||
| KernelFederationOptions = { | ||
| KernelFederationOptions & | ||
| KernelPortOptions = { | ||
| hostName: buildKernelHostName(options), | ||
| httpPath: prependSlash(options.path), | ||
| // Match the NodeJS Thrift driver, which surfaces INTERVAL columns as | ||
|
|
@@ -881,6 +884,11 @@ export function buildKernelConnectionOptions(options: ConnectionOptions): Kernel | |
| ...buildKernelProxyOptions(options), | ||
| }; | ||
|
|
||
| // Passed through as is; the kernel validates it. Omitted when not set. | ||
| if (options.port !== undefined && options.port !== null) { | ||
|
cathleeny marked this conversation as resolved.
Resolved
cathleeny marked this conversation as resolved.
Resolved
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thrift treats a falsy port as the default (the new test at DBSQLClient.test.ts:258 pins this), but this forwards NaN/''/false as is. With a #505 binding, |
||
| base.port = options.port; | ||
| } | ||
|
|
||
| if (options.enableGeoSpatialSupport !== undefined) { | ||
| if (typeof options.enableGeoSpatialSupport !== 'boolean') { | ||
| throw new HiveDriverError( | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.