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

feat: Add ability to POST an SSE request

Open Gao-Jun opened this issue 9 months ago • 1 comments

Background

Recently, I'm working on an SSE client to Tencent LKE interface, which use a POST request and reply SSE AIGC content. ruby-eventsource is a good gem to handle SSE replies, but cannot send request via POST.

Solution

This PR add a new param payload to initialize method. Some behaviors will be changed if payload is set.

  1. Request will be sent via HTTP POST method with payload content
  2. Reconnection is disabled to avoid duplicated POST

Gao-Jun avatar Apr 03 '25 08:04 Gao-Jun

Thank you for your interest and contribution. I do not have the capacity to review this PR quite yet, but I will get to it ASAP.

keelerm84 avatar Apr 04 '25 15:04 keelerm84

i need this feature as well. when will it get merged? Thanks

aunghtain avatar Jun 12 '25 05:06 aunghtain

Hi! I also am working on something that could really benefit from this feature, thanks ^^

ShreyanJain9 avatar Aug 13 '25 08:08 ShreyanJain9

Went ahead and added support for PUT method as well: https://github.com/launchdarkly/ruby-eventsource/pull/64

Can we get a review on both PRs @keelerm84 if possible so we can get these features out?

saada avatar Aug 14 '25 17:08 saada

@Gao-Jun and @saada I have made some modifications to this PR.

Instead of inferring the method from the presence of a payload, we are making those 2 separately provided items. This is more inline with some of our other event source SDKs.

Additionally, the request payload can be either a simple static value, or the result of a executing some payload function.

In a separate PR, I will introduce the ability to disable the retry functionality, which I also think should be explicitly defined rather than inferred.

keelerm84 avatar Aug 15 '25 19:08 keelerm84

@keelerm84 Thank you for your work. In the origin PR, when a POST request is closed, reconnection is disabled. code And this is not included in the final commits. Should we add this feature, or add a flag to handle this?

Gao-Jun avatar Aug 19 '25 08:08 Gao-Jun

@keelerm84 In the origin PR, when a POST request is closed, reconnection is disabled. code And this is not included in the final commits. Should we add this feature, or add a flag to handle this?

I had mentioned above I would make a separate PR for that. Sorry I didn't have time to do it previously, but I have just merged it here.

keelerm84 avatar Aug 20 '25 20:08 keelerm84