Skip to content

Commit

Permalink
fix: only deal with chunked transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasduteil committed Feb 1, 2024
1 parent 1b801a1 commit 73113b2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion example/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ www.use(
jsxRenderer(
({ children }) => {
return (
<html hx-ext="chunked-transfer">
<html hx-ext={["debug", "chunked-transfer"].join(", ")}>
<head>
<meta
name="viewport"
Expand Down
5 changes: 5 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ import type { HtmxExtension } from "htmx.org";
if (name === "htmx:beforeRequest") {
const xhr = evt.detail.xhr as XMLHttpRequest;
xhr.onprogress = function () {
const is_chunked =
xhr.getResponseHeader("Transfer-Encoding") === "chunked";

if (!is_chunked) return;

let response = xhr.response as string;

api.withExtensions(elt, function (extension) {
Expand Down

0 comments on commit 73113b2

Please sign in to comment.