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:
@@ -43,15 +43,17 @@ status_t
|
|||||||
BFileRequest::_ProtocolLoop()
|
BFileRequest::_ProtocolLoop()
|
||||||
{
|
{
|
||||||
BNode node(fUrl.Path().String());
|
BNode node(fUrl.Path().String());
|
||||||
node_ref ref;
|
if (node.IsSymLink())
|
||||||
status_t error = node.GetNodeRef(&ref);
|
{
|
||||||
if (error != B_OK)
|
// Traverse the symlink and start over
|
||||||
return error;
|
BEntry entry(fUrl.Path().String(), true);
|
||||||
|
node = BNode(&entry);
|
||||||
|
}
|
||||||
|
|
||||||
ssize_t transferredSize = 0;
|
ssize_t transferredSize = 0;
|
||||||
if (node.IsFile()) {
|
if (node.IsFile()) {
|
||||||
BFile file(fUrl.Path().String(), B_READ_ONLY);
|
BFile file(fUrl.Path().String(), B_READ_ONLY);
|
||||||
error = file.InitCheck();
|
status_t error = file.InitCheck();
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
@@ -84,15 +86,23 @@ BFileRequest::_ProtocolLoop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert(node.IsDirectory());
|
assert(node.IsDirectory());
|
||||||
|
node_ref ref;
|
||||||
|
status_t error = node.GetNodeRef(&ref);
|
||||||
|
if (error != B_OK)
|
||||||
|
return error;
|
||||||
|
|
||||||
BDirectory directory(&ref);
|
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.
|
// 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);
|
fListener->ConnectionOpened(this);
|
||||||
|
|
||||||
|
// Add a parent directory entry.
|
||||||
|
fListener->DataReceived(this, "+/,\t..\r\n",8);
|
||||||
|
}
|
||||||
|
|
||||||
int size = 0;
|
int size = 0;
|
||||||
char name[B_FILE_NAME_LENGTH];
|
char name[B_FILE_NAME_LENGTH];
|
||||||
BEntry entry;
|
BEntry entry;
|
||||||
|
|||||||
Reference in New Issue
Block a user