Skip to content

Commit 73113b2

Browse files
committed
fix: only deal with chunked transfer
1 parent 1b801a1 commit 73113b2

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

example/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ www.use(
3232
jsxRenderer(
3333
({ children }) => {
3434
return (
35-
<html hx-ext="chunked-transfer">
35+
<html hx-ext={["debug", "chunked-transfer"].join(", ")}>
3636
<head>
3737
<meta
3838
name="viewport"

index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ import type { HtmxExtension } from "htmx.org";
1717
if (name === "htmx:beforeRequest") {
1818
const xhr = evt.detail.xhr as XMLHttpRequest;
1919
xhr.onprogress = function () {
20+
const is_chunked =
21+
xhr.getResponseHeader("Transfer-Encoding") === "chunked";
22+
23+
if (!is_chunked) return;
24+
2025
let response = xhr.response as string;
2126

2227
api.withExtensions(elt, function (extension) {

0 commit comments

Comments
 (0)