Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"RequestNotAllowed" exception occurs when using twisted server to process soap11 requests #699

Open
LiqSolar opened this issue Oct 9, 2023 · 0 comments

Comments

@LiqSolar
Copy link

LiqSolar commented Oct 9, 2023

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.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant