Skip to content
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

add easy to use chunked transfer extension header #346

Merged
merged 2 commits into from
Aug 23, 2024

Conversation

fabge
Copy link
Contributor

@fabge fabge commented Aug 21, 2024


name: add easy to use header for transfer encoding chunked htmx extension
labels: chunked transfer

Related Issue
Issue 1911 in htmx repo

Proposed Changes
HTMX handles chunked transfer encoding of a response differently than in vanilla HTML. It waits for the complete response before displaying the response, instead of displaying already received chunks of content.

Types of changes
What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist
Go over all the following points, and put an x in all the boxes that apply:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I am aware that this is an nbdev project, and I have edited, cleaned, and synced the source notebooks instead of editing .py or .md files directly.

Additional Information
Any additional information, configuration or data that might be necessary to reproduce the issue.

Copy link

gitnotebooks bot commented Aug 21, 2024

Found 1 changed notebook. Review the changes at https://gitnotebooks.com/AnswerDotAI/fasthtml/pull/346

Copy link
Collaborator

@pydanny pydanny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The brevity and clarity of this PR is admirable. Offsetting the HTMX into a node package is also a bonus.

@@ -439,7 +440,7 @@ def __str__(self): return p
class FastHTML(Starlette):
def __init__(self, debug=False, routes=None, middleware=None, exception_handlers=None,
on_startup=None, on_shutdown=None, lifespan=None, hdrs=None, ftrs=None,
before=None, after=None, ws_hdr=False,
before=None, after=None, ws_hdr=False, ct_hdr=False,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does ct_hdr stand for? Chunked Transfer Header?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we rename it? i wasn't able to come up with something clearer

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the name. Just wanted to be explicit for when I document it. 😄

if ws_hdr: hdrs = [htmxwsscr] + hdrs
if htmx: hdrs = [htmxscr] + hdrs
if ws_hdr: hdrs = [htmxwssrc] + hdrs
if ct_hdr: hdrs = [htmxctsrc] + hdrs
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ What does ct_hdr stand for?

" if ws_hdr: hdrs = [htmxwsscr] + hdrs\n",
" if htmx: hdrs = [htmxscr] + hdrs\n",
" if ws_hdr: hdrs = [htmxwssrc] + hdrs\n",
" if ct_hdr: hdrs = [htmxctsrc] + hdrs\n",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ What does ct_hdr stand for?

@pydanny pydanny self-requested a review August 21, 2024 05:40
@jph00
Copy link
Contributor

jph00 commented Aug 22, 2024

Thank you, this looks good! Sorry I renamed the vars the other day, so there's a conflict now. Do you mind taking a look?

@jph00
Copy link
Contributor

jph00 commented Aug 22, 2024

Many thanks for this. Would you mind taking a look at the conflict please @fabge ?

@jph00 jph00 merged commit 83c9e02 into AnswerDotAI:main Aug 23, 2024
1 check passed
@jph00 jph00 added the enhancement New feature or request label Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants