gpt4 book ai didi

http - Apache Abdera 的分块传输编码问题

转载 作者:可可西里 更新时间:2023-11-01 15:30:15 27 4
gpt4 key购买 nike

我正在使用 Apache Abdera 将原子多部分数据发布到我的服务器,但遇到了一些我无法确定的奇怪问题。

这看起来像是分块传输编码的问题,但我没有足够的经验来确定。问题表现为服务器抛出错误,指示我发送给它的请求仅包含一个 MIME 部分,而不是所需的两个。我将 Wireshark 连接到界面并捕获了对话,它是这样的:

POST /sss/col-uri/2ee98ea1-f9ad-4f01-9b1c-cfa3c4a6dc3c HTTP/1.1
Host: localhost
Expect: 100-continue
Transfer-Encoding: chunked
Content-Type: multipart/related; boundary="1306399868259";type="application/atom+xml;type=entry"

服务器的响应:

HTTP/1.1 100 Continue

我的客户继续:

198
--1306399868259
Content-Type: application/atom+xml;type=entry
Content-Disposition: attachment; name="atom"

<entry xmlns="http://www.w3.org/2005/Atom"><title xmlns="http://purl.org/dc/terms/">Richard Woz Ere</title><bibliographicCitation xmlns="http://purl.org/dc/terms/">this is my citation</bibliographicCitation><content type="application/zip" src="cid:48bd9436-e8b6-4f68-aa83-5c88eda52fd4" /></entry>
0

b0e9

--1306399868259
Content-Type: application/zip
Content-Disposition: attachment; name="payload"; filename="example.zip"
Content-ID: <48bd9436-e8b6-4f68-aa83-5c88eda52fd4>
Packaging: http://purl.org/net/sword/package/SimpleZip

此时服务器响应:

HTTP/1.1 400 Bad Request
Date: Thu, 26 May 2011 08:51:08 GMT
Server: Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8l DAV/2 mod_wsgi/3.3 Python/2.6.1
Connection: close
Transfer-Encoding: chunked
Content-Type: text/xml

表示错误(很好理解)。我的服务器继续将一堆 base64 编码位流式传输到输出流上,但与此同时服务器没有监听,它已经确定请求是错误的。

不幸的是,我不负责 HTTP 层——这一切都由 Abdera 使用 Apache httpclient 处理。我执行此操作的代码如下所示:

client.execute("POST", url.toString(), new SWORDMultipartRequestEntity(deposit), options);

在这里,SWORDMultipartRequestEntity 是标准 Abdera MultipartRequestEntity 类的副本,其中包含一些额外的 header (例如,参见上面代码片段中的打包); “存款”参数只是一个包含原子部分和输入流的对象。

当附加调试器时,我很好地处理了这行代码,然后它消失在一个老鼠洞里,然后我又得到了这个错误。

有什么提示或技巧吗?我几乎用尽了攻击角度!

唯一让我印象深刻的是,在 atom:entry 文档之后,有一个单独带有“0”的换行符,它似乎是分块传输编码,代表“我完成了”。不确定它是如何到达那里的,或者它是否真的有任何影响。非常感谢帮助。

干杯,

理查德

最佳答案

孤独的0可能确实是个问题。我不知情的猜测是它是由对 flush() 的一些调用产生的,然后将整个缓冲区写入另一个 HTTP block 。不幸的是,在调用 flush 时,缓冲区已被刷新,因此其大小为零。因此,应该教导 HttpChunkedOutputFilter(或者无论如何调用它)而不是不需要刷新空缓冲区。

[更新:] 你应该在 ChunkedOutputStream 类中设置一个断点,尤其是 flush 方法。我只是看了它的代码,似乎还可以,但也许我遗漏了什么。

关于http - Apache Abdera 的分块传输编码问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6136528/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com