ruby-eventsource icon indicating copy to clipboard operation
ruby-eventsource copied to clipboard

feat: Add POST/PUT request support and optional parsing features

Open saada opened this issue 5 months ago • 3 comments

Summary

This PR adds four enhancements to the SSE client that improve flexibility while maintaining backward compatibility:

  • POST/PUT request support: Enables HTTP methods beyond GET with optional JSON payload support
  • Proxy authentication fix: Corrects proxy parameter names to use proxy_username/proxy_password instead of proxy_user/proxy_pass
  • Optional parsing mode: Adds ability to bypass SSE parsing for raw data streaming use cases
  • Optional SSL verification override: Allows disabling SSL verification for development/testing (secure by default)

Changes

POST/PUT Request Support

  • Added http_method parameter (defaults to "GET")
  • Added http_payload parameter for JSON payloads
  • Updated request logic to use specified method and payload

Proxy Authentication Fix

  • Fixed proxy option parameter names to match expected format
  • Changed from proxy_user/proxy_pass to proxy_username/proxy_password

Optional Parsing Mode

  • Added parse parameter (defaults to true)
  • When disabled, bypasses SSE parsing and returns raw chunks as events
  • Implemented via new BasicEventParser class

SSL Verification Override

  • Added verify_ssl parameter (defaults to true for security)
  • When set to false, disables SSL certificate verification
  • Useful for development, testing, and internal networks with self-signed certificates

Test plan

  • [x] All existing tests pass
  • [x] Backward compatibility maintained (all defaults preserve existing behavior)
  • [x] Security maintained by default (SSL verification enabled unless explicitly disabled)
  • [x] New features tested with existing test suite

Compatibility

All changes are backward compatible - existing code will continue to work exactly as before since all new parameters have sensible defaults that maintain current behavior and security posture.

saada avatar Aug 14 '25 17:08 saada

Hey @saada I am working through the other PR first, and then we can come back to take a look at the remaining changes here. Thank you for your patience!

keelerm84 avatar Aug 15 '25 20:08 keelerm84

@saada Thanks for your patience as we wrap up this work.

Most items have been addressed in separate PRs for individual review and are pending release.

Two remaining items:

OpenSSL change: https://github.com/launchdarkly/ruby-eventsource/pull/68 adds support for passing base HTTP options, which should eliminate the need for an explicit constructor option.

Parse option: Could you clarify your use case? If you need "raw streaming," what value does this library provide in that scenario over just connecting and streaming the data directly?

keelerm84 avatar Aug 28 '25 15:08 keelerm84

I went ahead and cut a release with the current functionality. If you can let me know about those questions, we can work to address those. In the meantime, hope the other stuff works well for you!

keelerm84 avatar Sep 04 '25 12:09 keelerm84