eventsource icon indicating copy to clipboard operation
eventsource copied to clipboard

want feature http post request

Open hansju-11 opened this issue 2 years ago • 10 comments

I'm looking for a way to send a http request as a client to the server via post. My server only use post not get method.

Example: curl https://....mynetworkprovider..../api/v3/events -X POST -H "Authorization: mypassword token" -H "Accept: text/event-stream" --data '{"identifiers":[{"ids":{"id":"12345678"}}]}'

hansju-11 avatar Feb 23 '23 06:02 hansju-11

Seems like this will not be added:

https://github.com/EventSource/eventsource/pull/292 https://github.com/EventSource/eventsource/pull/112 https://github.com/EventSource/eventsource/pull/138

Do you want to use this repo with The Things network? I tried that, but the events don't work, even with the POST request added

Patrick762 avatar Mar 12 '23 14:03 Patrick762

Hello @Patrick762 . yes I want to use it with 'The Things network". Do you have a working solution for that?

hansju-11 avatar Mar 16 '23 17:03 hansju-11

I'd also find POST support incredibly useful. There are lots of use cases for wanting to be able to send POST data to initiate an event stream response. I wish the devs would reconsider adding it as an option.

blerrgh avatar Mar 30 '23 03:03 blerrgh

The OpenAI GPT / ChatGPT API uses POST to return an EventSource stream ( https://platform.openai.com/docs/api-reference/completions/create ).

Not supporting POST on it makes this library useless for it.

Please reconsider supporting POST as in #292 .

cc @aslakhellesoy

LoopControl avatar Jun 06 '23 15:06 LoopControl

Would be great to have support for POST as it has become a "de facto" standard in some services like ChatGPT.

fasblom avatar Jan 27 '24 08:01 fasblom

Hi,

Any plan to support POST request with payload and headers?

cdaman123 avatar May 24 '24 09:05 cdaman123

Don’t bother.

The author is too stubborn to implement this simple request while every AI and LLM company is using POST with SSE.

LoopControl avatar May 24 '24 11:05 LoopControl

The API aims to be W3C compatible.

I would understand this to mean that the author wants to maintain some kind of accepted standard (as EventSource is based upon), not that they're stubborn.

As per web.dev:

The EventSource API is limited to making GET requests to the server. It's not possible to use POST requests with the EventSource API.

If you want something that accepts posts and streams responses, just write your own with a line-fed stream. What you want is not standard and doesn't belong in this particular implementation.

A common way to work with SSE that I've seen, for bi-directional communication, is POST'ing requests to another endpoint and using the SSE channel as a return stream. You could use something like Redis on the server side to emit events to all scaled nodes, depending on architecture, so you can scale such an implementation. No reason for them to be the same endpoint imo.

perry-mitchell avatar May 27 '24 10:05 perry-mitchell

I would understand this to mean that the author wants to maintain some kind of accepted standard (as EventSource is based upon), not that they're stubborn.

Meanwhile, OpenAI and every other LLM company is using POST in their APIs so this library won’t work.

The world moved on from the W3C SSE spec. This library stays stuck in the past.

LoopControl avatar May 27 '24 11:05 LoopControl

The world moved on from the W3C SSE spec.

No, I don't think it did: https://developer.mozilla.org/en-US/docs/Web/API/EventSource

Perhaps other libraries were written, or feature specifications suggested, but EventSource is GET only. Browsers support GET, and that spec is what (so far as I understand it) this library is based upon.

perry-mitchell avatar May 27 '24 12:05 perry-mitchell