Skip to content

Conversation

@harmon25
Copy link

@harmon25 harmon25 commented Nov 22, 2025

  • buffering support and improved state management when parsing requests
  • chunked sending for large responses
  • auto computes content-length header

Copilot assisted - might not be cleanest implementation of a fix for the issue, but it does the trick.

@harmon25 harmon25 changed the title [:httpd] Enhance HTTP request handling [:httpd] Fix HTTP larger request + response handling Nov 30, 2025
@harmon25 harmon25 changed the title [:httpd] Fix HTTP larger request + response handling [:httpd] Fix HTTP large request + response handling Nov 30, 2025
Copy link
Collaborator

@UncleGrumpy UncleGrumpy left a comment

Choose a reason for hiding this comment

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

Thanks for the submission! I did a few problems with this, but we are going to want @bettio or @pguyot to review this as well.

@UncleGrumpy
Copy link
Collaborator

Also, we don't have any CI checks for this repo yet, but would you please signoff all of your commits?

@harmon25
Copy link
Author

I could squash + sign when we are done with review? i can also open another PR with the commits signed

@harmon25 harmon25 requested a review from UncleGrumpy December 16, 2025 14:52
@UncleGrumpy
Copy link
Collaborator

UncleGrumpy commented Dec 16, 2025

I could squash + sign when we are done with review? i can also open another PR with the commits signed

Since this PR is focused on just the one bug fix, squash and sign will be great. No need to open a separate PR. I would have helped you get previous commits signed if that was necessary. ;-)

…te management

Signed-off-by: harmon25 <dougwright1@gmail.com>
Signed-off-by: harmon25 <dougwright1@gmail.com>
Signed-off-by: harmon25 <dougwright1@gmail.com>
@harmon25
Copy link
Author

OK i signed off with a force push!

@UncleGrumpy UncleGrumpy requested review from bettio and pguyot January 5, 2026 22:17
addr => any
}).
-define(DEFAULT_SOCKET_OPTIONS, #{}).
-define(MAX_SEND_CHUNK, 2048).
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if it would be better to set this a bit smaller, like 1024, so that it is less than most network MTU size (typically 1350-1500, depending on network). Exceeding the MTU will cause packet fragmentation, which isn't much of a problem for unix machines, but may not be handled as gracefully by microcontrollers.

Copy link
Author

Choose a reason for hiding this comment

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

in my independent fork i landed on 1460
https://github.com/harmon25/atomvm_httpd/blob/diagnostics/src/gen_tcp_server.erl#L49-L51

i will try and port those changes here also

Copy link
Collaborator

@UncleGrumpy UncleGrumpy Jan 7, 2026

Choose a reason for hiding this comment

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

That makes sense. 1500 is the most common MTU, and I think there is some tcp/ip overhead in each packet on top of what httpd is sending. If a VPN is used the MTU will be lower. I think 2048 is too high. We should actually expose this as a configuration option, with some lower default (like 1460 that you are using).

…r - incorporated from harmon25/atomvm_httpd

Signed-off-by: harmon25 <dougwright1@gmail.com>
Signed-off-by: harmon25 <dougwright1@gmail.com>
@schnittchen
Copy link

This breaks iolist response bodies: My response tuple contains a body which is a list of 19 elements, and I'm getting Content-Length: 19. I'm getting a 19 bytes response body which should be much larger.

…iodata)

Signed-off-by: harmon25 <dougwright1@gmail.com>
…ng frame parsing logic

Signed-off-by: harmon25 <dougwright1@gmail.com>
Signed-off-by: harmon25 <dougwright1@gmail.com>
@harmon25
Copy link
Author

All of the changes here I have mirrored in my standalone fork - which adds a bunch of tests via ex_unit - i have also ported over a change that allows for websocket frames that span multiple packets, as well as the ability to pass socket options through a new httpd.start/4

Sorry this PR got a bit out of hand...I wont add anything else but suggested fixes - will also test with the examples here to validate

@harmon25 harmon25 marked this pull request as draft January 11, 2026 21:19
@harmon25
Copy link
Author

untill i can validate the original example app i will keep this in draft - still seem to have issues...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants