Repository: aio-libs/aiohttp-sse

Issue:
will this support post method?

Discussion:
codecov[bot]: ## [Codecov](https://app.codecov.io/gh/aio-libs/aiohttp-sse/pull/452?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aio-libs) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Comparison is base [(`a096742`)](https://app.codecov.io/gh/aio-libs/aiohttp-sse/commit/a096742b51c8b5e5cbc29f6ad7d152a58b6e50d2?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aio-libs) 100.00% compared to head [(`3d72260`)](https://app.codecov.io/gh/aio-libs/aiohttp-sse/pull/452?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aio-libs) 100.00%.
> Report is 2 commits behind head on master.


<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff            @@
##            master      #452   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         4           
  Lines          439       434    -5     
  Branches        49        48    -1     
=========================================
- Hits           439       434    -5     
```



</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/aio-libs/aiohttp-sse/pull/452?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aio-libs).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aio-libs).


Patch:
diff --git a/aiohttp_sse/__init__.py b/aiohttp_sse/__init__.py
index d28407f..8367e1f 100644
--- a/aiohttp_sse/__init__.py
+++ b/aiohttp_sse/__init__.py
@@ -6,13 +6,7 @@ from types import TracebackType
 from typing import Any, Mapping, Optional, Type, TypeVar, Union, overload
 
 from aiohttp.abc import AbstractStreamWriter
-from aiohttp.web import (
-    BaseRequest,
-    ContentCoding,
-    HTTPMethodNotAllowed,
-    Request,
-    StreamResponse,
-)
+from aiohttp.web import BaseRequest, ContentCoding, Request, StreamResponse
 
 from .helpers import _ContextManager
 
@@ -78,9 +72,6 @@ class EventSourceResponse(StreamResponse):
 
         :param request: regular aiohttp.web.Request.
         """
-        if request.method != "GET":
-            raise HTTPMethodNotAllowed(request.method, ["GET"])
-
         if not self.prepared:
             writer = await super().prepare(request)
             self._ping_task = asyncio.create_task(self._ping())


Test patch:
diff --git a/tests/test_sse.py b/tests/test_sse.py
index 03489b8..6c0d0d7 100644
--- a/tests/test_sse.py
+++ b/tests/test_sse.py
@@ -73,12 +73,6 @@ async def test_func(
         "id: xyz\r\nevent: bar\r\ndata: foo\r\nretry: 1\r\n\r\n"
     )
     assert streamed_data == expected
-
-    # check that EventSourceResponse object works only
-    # with GET method
-    resp = await session.request("POST", url)
-    assert 405 == resp.status
-    resp.close()
     await runner.cleanup()
 
 
@@ -553,3 +547,35 @@ class TestLastEventId:
         sse = EventSourceResponse()
         with pytest.raises(RuntimeError):
             _ = sse.last_event_id
+
+
+@pytest.mark.parametrize(
+    "http_method",
+    ("GET", "POST", "PUT", "DELETE", "PATCH"),
+)
+async def test_http_methods(
+    unused_tcp_port: int,
+    session: ClientSession,
+    http_method: str,
+) -> None:
+    async def handler(request: web.Request) -> EventSourceResponse:
+        async with sse_response(request) as sse:
+            await sse.send("foo")
+        return sse
+
+    app = web.Application()
+    app.router.add_route(http_method, "/", handler)
+
+    host = "127.0.0.1"
+    runner = await make_runner(app, host, unused_tcp_port)
+    url = f"http://127.0.0.1:{unused_tcp_port}/"
+
+    resp = await session.request(http_method, url)
+    assert resp.status == 200
+
+    # check streamed data
+    streamed_data = await resp.text()
+    expected = "data: foo\r\n\r\n"
+    assert streamed_data == expected
+
+    await runner.cleanup()