Chewbaka
Chewbaka

Reputation: 1

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.

How do I get the content length of the file I'm "putting"?

Upvotes: 0

Views: 749

Answers (1)

Brad at Kademi
Brad at Kademi

Reputation: 1320

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. 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.

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.

Note that if you are extending the tomcat webdav servlet, you might also want to consider using milton.io. Its a webdav servlet intended to allow a pluggable backend. It also ships with a filesystem implementation equivalent to tomcat's webdav servlet.

Upvotes: 1

Related Questions