FreddyMSchubert / 42_webserv

πŸ§¨πŸŽΈπŸ€˜πŸš€ Full implementation of our own HTTP server. [42 PROJECT]
3 stars 0 forks source link

fix chunked transfer #24

Open FreddyMSchubert opened 4 weeks ago

FreddyMSchubert commented 4 weeks ago

its very broken not working at all

FreddyMSchubert commented 1 week ago

Well, this needs a lot more attention.

We can't just read out all of the data and then parse it separately, we need to actually collect the data live as we receive it. Otherwise, if someone was to send an infinite data stream, our server would be blocked forever, which is not allowed as per the subject.

I've deleted the previous branch, this needs a larger rework.

Lemme sketch out how I think this might work before getting started, anything might change:

So, lets make

  1. Server calls on ConnectionManager to update
  2. ConnectionManager gets up-to-date infos using poll
  3. ConnectionManager goes through connections.
    • If they were closed from the client-side, call closing function.
    • If they are still open, call its Socket to read new data & append to buffer string
    • If any buffer string exceeds it's allowed size, send a 413 and close connection
  4. If IsClosed returns true, parse it & respond & close

IsClosed function

Closing function

Given that the goal of this project is merely to serve a fully static website, sending in chunk transfer encoding is not something I deem to be strictly necessary at the moment. I'd just... not do that.

Reptudn commented 1 week ago

sounds good lets do that i found a good source on how other people did it here