mirror of
https://github.com/lancedb/lancedb.git
synced 2025-12-22 21:09:58 +00:00
test to reproduce node extra headers issue
This commit is contained in:
@@ -108,7 +108,10 @@ describe("remote connection", () => {
|
||||
it("should pass on requested extra headers", async () => {
|
||||
await withMockDatabase(
|
||||
(req, res) => {
|
||||
expect(req.headers["x-my-header"]).toEqual("my-value");
|
||||
expect(req.headers["foo"]).toEqual("1");
|
||||
expect(req.headers["bar"]).toEqual("2");
|
||||
expect(req.headers["baz"]).toEqual("3");
|
||||
expect(req.headers["x-log-attrs"]).toEqual("foo, bar, baz");
|
||||
|
||||
const body = JSON.stringify({ tables: [] });
|
||||
res.writeHead(200, { "Content-Type": "application/json" }).end(body);
|
||||
@@ -119,9 +122,12 @@ describe("remote connection", () => {
|
||||
},
|
||||
{
|
||||
clientConfig: {
|
||||
extraHeaders: {
|
||||
"x-my-header": "my-value",
|
||||
},
|
||||
extraHeaders: {
|
||||
"x-log-attrs": "foo, bar, baz",
|
||||
foo: "1",
|
||||
bar: "2",
|
||||
baz: "3",
|
||||
},
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-FileCopyrightText: Copyright The LanceDB Authors
|
||||
|
||||
use http::HeaderName;
|
||||
use log::debug;
|
||||
use log::{debug, info};
|
||||
use reqwest::{
|
||||
header::{HeaderMap, HeaderValue},
|
||||
Body, Request, RequestBuilder, Response,
|
||||
@@ -324,6 +324,7 @@ impl<S: HttpSend> RestfulLanceDbClient<S> {
|
||||
}
|
||||
|
||||
for (key, value) in &config.extra_headers {
|
||||
info!("header: {}={}", key, value);
|
||||
let key_parsed = HeaderName::from_str(key).map_err(|_| Error::InvalidInput {
|
||||
message: format!("non-ascii value for header '{}' provided", key),
|
||||
})?;
|
||||
|
||||
Reference in New Issue
Block a user