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

streaming upload example #206

Merged
merged 2 commits into from
Jan 3, 2024
Merged

streaming upload example #206

merged 2 commits into from
Jan 3, 2024

Conversation

pschrammel
Copy link
Contributor

Types of Changes

  • Adding Example

streaming_upload example added with support for 100-continue (which is hack but works). There's still an issue that EOFError is not rescuable (run the "ab" command as described in the README and you'll see it).

Contribution

@pschrammel
Copy link
Contributor Author

@ioquatix can you have a short look at at? I still can't understand why it sometimes is crashing. It might have to do with exceptions in a fiber. Perhaps you have an idea how to make the thing robust.

@pschrammel
Copy link
Contributor Author

@ioquatix do you have time to give me some hints?

@ioquatix
Copy link
Member

ioquatix commented Jan 2, 2024

Sorry, I'll take a look today.

@ioquatix ioquatix closed this Jan 2, 2024
@ioquatix ioquatix reopened this Jan 2, 2024
@ioquatix
Copy link
Member

ioquatix commented Jan 3, 2024

The example looks okay to me, I'll merge it and try it out.

@ioquatix ioquatix merged commit 11c4b66 into socketry:main Jan 3, 2024
17 of 20 checks passed
@ioquatix
Copy link
Member

ioquatix commented Jan 3, 2024

Nice example! I made some minor changes and played around with the code. It looks pretty decent to me. Notably we introduced support for interim responses:

  if env['REQUEST_METHOD'] == 'POST'
    if request.headers['expect']&.include?('100-continue')
      request.write_interim_response(Protocol::HTTP::Response[100])
    end

I think that the reason why you are getting corruption at the end is probably ab is not gracefully shutting down and instead just dropping all the connections at the end. I'm not sure why it would do this so I'll investigate a bit further, still not 100% convinced there isn't a bug somewhere on my end.

@ioquatix
Copy link
Member

ioquatix commented Jan 3, 2024

Yeah, my guess is when you have -c n where n > 1, ab will write as many requests per connection as possible, and when it hits the request limit, immediately terminates all connections. In a real world system, you'd need to just drop these requests (i.e. EOFError represents a failed upload).

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.

2 participants