Sending HTTP headers
kpocza opened this issue · 5 comments
When doing a PoC for MSOffice/LibreOffice editing feature while putting the documents on a WebDAV address pointed by a href links I noticed that the HTTP headers are not sent in case of GET requests.
NWebDav is hosted on ASP.NET (not Core).
To temporarily overcome the issue I had to add a flush method that flushes the content to the response before starting to write the actual content. The flush is called before the "if (!head) await CopyToAsync" statement in GetAndHeadHandler.cs.
I don't know if something similar is required for ASP.NET Core, HttpListener and for other HTTP verbs.
Could you please post the code that you have changed?
Sure.
Please give me some time as I made the changes on my office computer and I'm on holiday at the moment. I can do it earliest at the end of next week.
I've created a diff:
flush.zip
The ASP.NET version has been changed and tested in case of GET requests only. I don't know how the library behaves in other environments and other VERBs. This is the reason I send just a diff and not a pull request.
Can you explain how I can reproduce the original problem? I rather not pollute the generic IHttpResponse
namespace for these "edge-cases".
I've run two test cases. In both cases I applied a disk based web handler pointing to the same location. My minisite hosted a page having a link to a LibreOffice odt file this way: doc2
I clicked the link to start editing in LibreOffice.
Specialities of the two test cases:
- The first one was performed with the original NWebDav library
- The second one was performed with the modified library according to flush.zip attached before
I've captured the communication via Fiddler.
Line 5 is the result of the GET request sending content type of text/html. Line 3, 4 are propfinds also with bad content type.
Line 5 shows the right content type here (while propfinds are still wrong as I haven't modified the respective handler).