简体   繁体   English

Tomcat WebDAV缺少Content-Length标头

[英]Tomcat WebDAV is missing Content-Length header

I'm using Tomcat's WebDAV servlet and it seems that I can't get the header "Content-Length" when I'm issuing a PUT request. 我正在使用Tomcat的WebDAV Servlet,并且在发出PUT请求时似乎无法获取标头“ Content-Length”。

How do I get the content length of the file I'm "putting"? 如何获取我正在“放入”的文件的内容长度?

Assuming you mean that you're writing code which is part of the server-side PUT operation - ie you're extending the webdav servlet or something. 假设您的意思是您正在编写服务器端PUT操作一部分的代码-即,您正在扩展webdav servlet或其他内容。 Then if the client has sent a file via PUT and there is no content-length header then you need to buffer the bytes (probably to disk) and then use the resulting buffered data to give you the length. 然后,如果客户端已通过PUT发送文件,并且没有content-length头,则需要缓冲字节(可能是磁盘),然后使用生成的缓冲数据为您提供长度。

Its perfectly legal for clients to send a file without a content length. 客户发送没有内容长度的文件是完全合法的。 In that case they simply drop the TCP connection to indicate EOF. 在那种情况下,他们只是丢弃TCP连接以指示EOF。

Note that if you are extending the tomcat webdav servlet, you might also want to consider using milton.io. 请注意,如果要扩展tomcat webdav servlet,则可能还需要考虑使用milton.io。 Its a webdav servlet intended to allow a pluggable backend. 它是一个webdav servlet,旨在允许可插入的后端。 It also ships with a filesystem implementation equivalent to tomcat's webdav servlet. 它还附带与tomcat的webdav servlet等效的文件系统实现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM