Hello Geoff,

Geoff Hutchison wrote:
> 
> On Tue, 21 Dec 1999, Alexis Mikhailov wrote:
> 
> > I don't think that directories should return links to files, not for
> > file:// method. file:// should refer only to files existing on local
> > disk.
> 
> Yes, I agree with this, but I'll bet as soon as we put it in, someone will
> say "how come it doesn't index directories!" ;-) You're right though and
> let's take one thing at a time.

May be index every file in directory on directory references?

> That would be wonderful. We could also start off with just the
> extension-based MIME files, which would help a lot as well. The only
> problem for us is how to figure out what's server-parsed!

1. Add extensions for server-parsed to bad_extensions and not index them
at all.
2. Create server_parsed variable (with extensions of s/p files for
example) in config file to force local_urs directive to ignore such
files.
If file:// reference points to s/p file, ignore this file.

> > May be just change reading of files to line by line? As a additional
> > benefit it will allow using of FIFOs.
> 
> Yes this would be something to try. We did it line-by-line before, then
> changed it to the current method to make it more like the HTTP method. As
> you know, we do a lot of other stuff line-by-line! :-)

Modified HtFile attached.

Alexis
//
// HtFile.cc
//
// HtFile: Interface classes for retriving local documents
//
// Including:
//       -  Generic class
//
// Part of the ht://Dig package   <http://www.htdig.org/>
// Copyright (c) 1999 The ht://Dig Group
// For copyright details, see the file COPYING in your distribution
// or the GNU Public License version 2 or later
// <http://www.gnu.org/copyleft/gpl.html>
//
// $Id$ 
//

#include "lib.h"
#include "Transport.h"
#include "HtFile.h"

#include <signal.h>
#include <sys/types.h>
#include <ctype.h>
#include <iostream.h>
#include <stdio.h> // for sscanf
#include <sys/stat.h>
#include <unistd.h>
#include <fstream.h>


///////
   //    HtFile_Response class
///////


// Construction

HtFile_Response::HtFile_Response()
{
}


// Destruction

HtFile_Response::~HtFile_Response()
{
}

///////
   //    HtFile generic class
   //
   //    
///////


// Construction

HtFile::HtFile()
{
   _modification_time=NULL;
}

// Destruction

HtFile::~HtFile()
{
   // It's empty
}


///////
   //    Manages the requesting process
///////

HtFile::DocStatus HtFile::Request()
{
   // Reset the response
   _response.Reset();
   
   struct stat stat_buf;
   // Check that it exists, and is a regular file.
   // Should we allow FIFO's?
   if (stat(_url.path(), &stat_buf) != 0 || !S_ISREG(stat_buf.st_mode))
     return Document_not_found;
   if (_modification_time && *_modification_time >= HtDateTime(stat_buf.st_mtime))
     return Document_not_changed;

   char *ext = strrchr(_url.path(), '.');
   if (ext == NULL)
     return Document_not_local;
   if ((mystrcasecmp(ext, ".html") == 0) || (mystrcasecmp(ext, ".htm") == 0))
     _response._content_type = "text/html";
   else if (mystrcasecmp(ext, ".txt") == 0)
     _response._content_type = "text/plain";
   else
     return Transport::Document_not_local;

   _response._modification_time = new HtDateTime(stat_buf.st_mtime);

   ifstream in(_url.path());
   if (!in)
     return Document_not_found;

   String tmp;
   while (in >> tmp)
     _response._contents.append(tmp);

   _response._content_length = _response._contents.length();
   _response._document_length = _response._contents.length();
   _response._status_code = 0;

   if (debug > 2)
     cout << "Read a total of " << _response._document_length << " bytes\n";
   return Document_ok;
}

HtFile::DocStatus HtFile::GetDocumentStatus()
{ 
   // Let's give a look at the return status code
   if (_response._status_code == -1)
      return Document_not_found;
   return Document_ok;
}


------------------------------------
To unsubscribe from the htdig3-dev mailing list, send a message to
[EMAIL PROTECTED] 
You will receive a message to confirm this. 

Reply via email to