FileRequest: multiple fixes

* Don't crash when opening a symlink, traverse it instead.
* Add a ".." entry to navigate to the parent folder
* Set the encoding to utf-8 in the MIME header, but this doesn't seem to
work.
This commit is contained in:
Adrien Destugues
2014-01-15 20:20:58 +01:00
parent 4e4396fa46
commit 00b65b2d7b
+18 -8
View File
@@ -43,15 +43,17 @@ status_t
BFileRequest::_ProtocolLoop()
{
BNode node(fUrl.Path().String());
node_ref ref;
status_t error = node.GetNodeRef(&ref);
if (error != B_OK)
return error;
if (node.IsSymLink())
{
// Traverse the symlink and start over
BEntry entry(fUrl.Path().String(), true);
node = BNode(&entry);
}
ssize_t transferredSize = 0;
if (node.IsFile()) {
BFile file(fUrl.Path().String(), B_READ_ONLY);
error = file.InitCheck();
status_t error = file.InitCheck();
if (error != B_OK)
return error;
@@ -84,15 +86,23 @@ BFileRequest::_ProtocolLoop()
}
assert(node.IsDirectory());
node_ref ref;
status_t error = node.GetNodeRef(&ref);
if (error != B_OK)
return error;
BDirectory directory(&ref);
fResult.SetContentType("application/x-ftp-directory");
fResult.SetContentType("application/x-ftp-directory; charset=utf-8");
// This tells WebKit to use its FTP directory rendering code.
// Send all notifications to listener, if any
if (fListener != NULL)
if (fListener != NULL) {
fListener->ConnectionOpened(this);
// Add a parent directory entry.
fListener->DataReceived(this, "+/,\t..\r\n",8);
}
int size = 0;
char name[B_FILE_NAME_LENGTH];
BEntry entry;