aio-libs / aiohttp-sse

Server-sent events support for aiohttp
Other
194 stars 35 forks source link

will this support post method? #414

Closed systemview2018 closed 6 months ago

kunkanader commented 9 months ago

+1

Olegt0rr commented 7 months ago

@systemview2018

Server-Sent-Events was created to GET streamed information from server. If you wanna POST something - use basic HTTP requests

Dreamsorcerer commented 6 months ago

Yeah, I think this needs more information and rationale. I'm assuming you mean to open an SSE connection through a POST request. But, browser's EventSource do not support this, so it seems like an odd thing to want.

Also, it's posed as a question, not an issue, which suggests to me you haven't even tried it. Surely, you can change GET to POST on your endpoint and tell us if it works or not.

justin-together commented 6 months ago

Streaming SSE in response to POST is a very common extension used by:

And supported by various extended EventSource packages (which also extend EventSource in other ways, like allowing sending Authorization headers):

Olegt0rr commented 6 months ago

Also, it's posed as a question, not an issue, which suggests to me you haven't even tried it. Surely, you can change GET to POST on your endpoint and tell us if it works or not.

aiohttp-sse explicitly restricts all methods except GET on prepare https://github.com/aio-libs/aiohttp-sse/blob/a8ef551ea6185c3a4f52d98f94d6d1911fe1c39d/aiohttp_sse/__init__.py#L62-L63

Default EventSource client can't connect with other methods, but custom clients can (example). We just need to release restrictions and give this responsibility to developer. If they want to use library this way - why not? :)

Dreamsorcerer commented 5 months ago

aiohttp-sse explicitly restricts all methods except GET on prepare

Hmm, it's not clear why that check was added: https://github.com/aio-libs/aiohttp-sse/commit/16f188464771b42751300bbfa736ec85be943545

The commit appears to be completely unrelated. If it's just a case of skipping a check, then I think it'd be fine to support it.