Skip to content

Commit

Permalink
Improve handling of 'text/plain' files
Browse files Browse the repository at this point in the history
Connected to duckdb#1580
  • Loading branch information
carlopi committed Jan 16, 2024
1 parent 37d1886 commit bc32ad0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/duckdb-wasm/src/bindings/runtime_browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ export const BROWSER_RUNTIME: DuckDBRuntime & {
} else {
xhr.open('HEAD', file.dataUrl!, false);
}
// See https://github.com/duckdb/duckdb-wasm/issues/1580
xhr.setRequestHeader('Range', `bytes=0-`);
xhr.send(null);

// Expect 200 for existing files that we will overwrite or 404 for non-existent files can be created
Expand Down Expand Up @@ -287,6 +289,8 @@ export const BROWSER_RUNTIME: DuckDBRuntime & {
} else {
xhr.open('HEAD', path!, false);
}
// See https://github.com/duckdb/duckdb-wasm/issues/1580
xhr.setRequestHeader('Range', `bytes=0-`);
xhr.send(null);
if (xhr.status != 200 && xhr.status !== 206) {
// Pre-signed resources on S3 in common configurations fail on any HEAD request
Expand Down Expand Up @@ -338,6 +342,8 @@ export const BROWSER_RUNTIME: DuckDBRuntime & {
} else {
xhr.open('HEAD', path!, false);
}
// See https://github.com/duckdb/duckdb-wasm/issues/1580
xhr.setRequestHeader('Range', `bytes=0-`);
xhr.send(null);
return xhr.status == 206 || xhr.status == 200;
}
Expand Down

0 comments on commit bc32ad0

Please sign in to comment.