修复soaplib以支持分块请求

时间:2011-03-18 11:23:32

标签: python web-services soap soaplib

我有使用soaplib构建的soap webservice, 但是如果客户端发送了chunked请求,它就会失败

length = req_env.get("CONTENT_LENGTH")
body = input.read(int(length))
因为长度是''(空字符串),任何想法如何修复soaplib?

1 个答案:

答案 0 :(得分:0)

有点难看,但看起来很有效:

            if '' != length:
                body = input.read(int(length))
            elif req_env.get("HTTP_TRANSFER_ENCODING").lower() == 'chunked':

                chunk_size = int(input.readline(), 16)
                while chunk_size > 0:
                    chunk_read_size = 0
                    tmp  = input.read(chunk_size)
                    chunk_read_size += len(tmp)
                    body += tmp
                    while chunk_read_size