Review Request: Improve mimetype detection for wevdav:// links

Dawit Alemayehu adawit at kde.org
Sat Dec 1 19:07:24 GMT 2012


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/107518/#review22888
-----------------------------------------------------------


Why not simply use KIO::get instead of KIO::mimetype ? For the record, one should never use KIO::mimetype for HTTP based protocols since it results in a HEAD request. It is a well known issue that sending a HEAD request to webservers, which for the most part generate content dynamically, is a useless proposition because the mime type they return on such request will be wrong most of the time (HEAD will not result in the generation of the content and hence the default type will probably be returned). Hence, the rule about not using KIO::mimetype for HTTP or any of its extensions like webdav. Instead you should simply do a KIO::get request by following the instructions on how to put a request on hold if all you want to do is determine the real mimetype of the content. This has even the side benefit of being able to use the same connection if you then decide to pull down the content afterwards. 

Havig said that, I am unable to test your patch because I do not have access. The links you provided are protected by HTTP authorization.

- Dawit Alemayehu


On Nov. 29, 2012, 5:42 p.m., Sergey Borovkov wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/107518/
> -----------------------------------------------------------
> 
> (Updated Nov. 29, 2012, 5:42 p.m.)
> 
> 
> Review request for kdelibs.
> 
> 
> Description
> -------
> 
> KIO::mimetype() when used on webdav:// url returned empty string on some servers, empty string on others. After some investigating I found out that mime-type is determined like for usual http:// links - i.e. making HEAD requests.
> But this is problematic - some servers do not return content type for webdav links (for example this behavior occurred on webdavs://webdav.yandex.ru). Even if server returns content-type it can be wrong - for directories HEAD request return text/xml (that happens because webdav directories are simply xml listings).
> I tried to fix this by essentially calling stat on webdav url and emitting mimetype when it's found.
> 
> 
> Diffs
> -----
> 
>   kioslave/http/http.h 4d0b029 
>   kioslave/http/http.cpp b7f8e8d 
> 
> Diff: http://git.reviewboard.kde.org/r/107518/diff/
> 
> 
> Testing
> -------
> 
> Tested this on two webdav servers (webdavs://webdav.yandex.ru and webdavs://dav.2safe.com).
> 
> 
> Thanks,
> 
> Sergey Borovkov
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20121201/1d2ef719/attachment.htm>


More information about the kde-core-devel mailing list