我如何使用“期望:100-继续”扭曲网络中的标题?
我一直在使用 AkaDAV(一个基于 Twisted 的 WebDAV 服务器),并且我正在尝试支持完整的 < href="http://www.webdav.org/neon/litmus/" rel="nofollow">litmus 测试套件。我目前陷入了 http 子套件的困境。
具体来说,我可以运行:
$ TESTS=http litmus http://localhost:8080/steder/
-> running `http':
0. init.................. pass
1. begin................. pass
2. expect100............. FAIL (timeout waiting for interim response)
3. finish................ pass
此测试基本上执行以下操作:
- 打开 WebDAV 服务器的套接字
发出以下 PUT:
PUT /steder/litmus/expect100 HTTP/1.1 主机:本地主机:8080 内容长度:100 预期:100-继续
等待响应
HTTP/1.1 100继续
响应。- 上传 100 字节内容有效负载
这里令人困惑的是,看起来这个 PUT 请求从未发送到 Twisted。作为健全性检查,我已经确认通过 curl -X PUT ...
发出的 PUT 请求有效,因此这个测试用例似乎有一些特别之处。
有什么想法我可能做错了吗?如果有帮助的话,我很乐意分享源代码。
编辑:
经过更多查看后,这似乎是一个已知的 twisted.web
问题:http://twistedmatrix.com/trac/ticket/4673
有人知道解决方法吗?
I've been working with AkaDAV, a Twisted based WebDAV server, and I'm trying to support the full litmus test suite. I'm currently stuck on the http sub-suite.
Specifically, I can run:
$ TESTS=http litmus http://localhost:8080/steder/
-> running `http':
0. init.................. pass
1. begin................. pass
2. expect100............. FAIL (timeout waiting for interim response)
3. finish................ pass
This test basically does the following:
- Open a socket to the WebDAV server
Issue the following PUT:
PUT /steder/litmus/expect100 HTTP/1.1
Host: localhost:8080
Content-Length: 100
Expect: 100-continuewaits for a response
HTTP/1.1 100 Continue
response.- uploads 100 byte content payload
The confusing thing here is that it looks like this PUT request never makes it to Twisted. As a sanity check I've confirmed that PUT requests issued through curl -X PUT ...
work so it seems like there's something special about this testcase.
Any ideas what I may be doing wrong? I'm happy to share sourcecode if that helps.
EDIT:
After a little more looking around it appears that this is a known twisted.web
issue: http://twistedmatrix.com/trac/ticket/4673
Does anyone know of a workaround?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过更多调查后,我们很清楚如何修改 HTTP 协议实现来支持此用例。看起来官方修复很快就会在 Twisted 中发布,但与此同时我正在使用它作为解决方法。
只需在实例化您的
Site
(或twhttp.HTTPFactory
)之前包含此代码:我想如果您需要在协议级别进行其他修改,您可以使用相同的方法来修补它们也在。它不一定很漂亮,但对我有用。
After some more investigation it's pretty clear how to modify the HTTP protocol implementation to support this use case. It looks like the official fix will be in Twisted soon but in the meantime I'm using this as a workaround.
Just include this code before you instantiate your
Site
(ort.w.http.HTTPFactory
):I imagine if you needed other modifications at the protocol level you could use this same method to patch them in as well. It ain't necessarily pretty but it works for me.