-
Notifications
You must be signed in to change notification settings - Fork 322
Open
Description
Describe the bug
sypne reports ERROR:spyne.server.twisted.http:RequestNotAllowed(Client.RequestNotAllowed: 'You must issue a POST request with the Content-Type header properly set.') when using twisted server to handle soap11 requests.
To Reproduce
I am using Python 3.7.9, Win10 x64.
This issue can be reproduced using the sample code in
http://spyne.io/#inprot=Soap11&outprot=Soap11&s=rpc&tpt=TwistedWebResource&validator=true
class HelloWorldService(ServiceBase):
@rpc(Unicode, Integer, _returns=Iterable(Unicode))
def say_hello(ctx, name, times):
for i in range(times):
yield 'Hello, %s' % name
application = Application([HelloWorldService],
tns='spyne.examples.hello',
in_protocol=Soap11(validator='lxml'),
out_protocol=Soap11()
)
if __name__ == '__main__':
resource = TwistedWebResource(application)
site = Site(resource)
reactor.listenTCP(8000, site, interface='0.0.0.0')
reactor.run()
Additional context
The issue is that when using twisted, the value of http_verb variable in the following code is b‘POST’, so an exception will always be raised.
content_type = ctx.transport.get_request_content_type()
http_verb = ctx.transport.get_request_method()
if content_type is None or http_verb != "POST":
ctx.transport.resp_code = HTTP_405
raise RequestNotAllowed(
"You must issue a POST request with the Content-Type "
"header properly set.")
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels