[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[gopher] Getting file info from an URI??

Hi Gopherers,

As I've written not so long ago, I'm working on a Gopher method for the
GNOME Virtual File System (gnome-vfs).

The problem with gnome-vfs is that it works extensively with URI's. It
is very common for a gnome-vfs method to be required to fetch file
information (like mime-type) given _only_ an URI.

Now the Gopher standard writes: "[t]he selector string should mean
nothing to the client software; it should never be modified by the
client." Now this implies three things: first, one _cannot_ determine a
file type by looking at the format of an URI. Second, one _cannot_
assume that a Gopher selector is seperated by slashes. And third, even
if one could do just that, one _cannot_ assume that a "parent directory"
lists the child.

Practical example: gopher.heatdeath.org uses selectors like "1/foo", but
you can't just list the "1" directory to find the item "foo" there (try
it; it doesn't work).

So my question is: how _can_ I find the file information given only an

I figured out a few solutions, all with their own problems:

1) Use the Gopher+ "!" (information) selector feature
   Problem: requires Gopher+. Can one assume Gopher+ nowadays?
   Or are there still many "non-plus" Gopher servers around?
   Please comment on this.

2) Make a pool of recently downloaded directory listings from
   which one can search for the given selector and get the file
   description and type.
   Problem: when do you know a dirlisting can be deleted from the
   pool? I guess you can't be sure until the end of the session.

3) Download part of the file and "sniff" the mime type.
   Problem: that still doesn't give you a description (name)
   for the file, only the mime type.

I'd fancy any of these solutions (or even another if there is one) if
only I could solve their problems.

I really wonder if one can assume the availability of Gopher+ nowadays.
Gopher+ has a few advanced features that may be very useful in my
implementation, and that would keep out "hacks" like 2) and 3). Yet I
don't want sites to be inaccessible just because they don't use Gopher+.

Maybe I'll have to work out 2 solutions, one for Gopher and one for

Anyway, I'd like to hear your comments.



Reply to: