aleph-im / aleph-sdk-python

Python SDK library for the Aleph.im network
MIT License
3 stars 4 forks source link

Fix: support 405 from POST /messages in broadcast fallback #60

Closed odesenfans closed 11 months ago

odesenfans commented 11 months ago

Problem: a user reports that publishing a message falls because of a 405 error returned from POST /messages. The fallback only takes 404 into account, but a 405 is actually more likely because GET /messages exists.

Solution: accept both 404 and 405 as a sign that the node does not support POST /messages.

hoh commented 11 months ago

From the spec:

The server must generate an Allow header field in a 405 status code response. The field must contain a list of methods that the target resource currently supports.

Is this the case on pyaleph @odesenfans ?

Source: https://developer.mozilla.org/en-US/docs/web/http/status/405

odesenfans commented 11 months ago

@hoh yes, this is managed by aiohttp:

curl -i -X POST api2.aleph.im/
HTTP/1.1 405 Method Not Allowed
Server: nginx/1.17.6
Date: Mon, 18 Sep 2023 16:35:24 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 23
Connection: keep-alive
Allow: GET,HEAD,OPTIONS