[jcifs] '/' required at the end of directories

Christopher R. Hertel crh at ubiqx.mn.org
Mon Jan 20 11:35:29 EST 2003

"Allen, Michael B (RSCH)" wrote:
> > You said above that the java.net.URL object needs to know ahead of time what
> > type of object something is before it accesses that object.  That's
> > a big chicken-and-egg problem, and I'd go so far as to call it a bug in
> > the design of java.net.URL.  I probably need a much better understanding
> > of that class before I complain, but...
> >
>         RFC 2396 section 5.2. Resolving Relative References to Absolute Form:
>            ...
>            6) If this step is reached, then we are resolving a relative-path
>               reference.  The relative path needs to be merged with the base
>               URI's path.  Although there are many ways to do this, we will
>               describe a simple method using a separate string buffer.
>               a) All but the last segment of the base URI's path component is
>                  copied to the buffer.  In other words, any characters after the
>                  last (right-most) slash character, if any, are excluded.

Which is, once again, syntax.  It also fails to address what I suggested. 
I'm saying that once the semantics of the URL are known the syntax can be
corrected.  I don't disagree with the syntactic method given above, but it
doesn't address what I said. It still is a chicken-and-egg problem.
> > The distinction is moot for the HTTP protocol, since the web server will
> > send HTML or some other mime-type back in any case.  That is, if you enter
> > "http://server/directory" you will most likely get back an HTML document
> > that is the listing of the directory contents.
> >
>         Notice if you send an HTTP request like:
>         GET /foo HTTP/1.1
>         and foo turns out to be a directory you will get:
>         HTTP/1.1 301 Moved Permanently
>         ...
>         Location: http://server.com/foo/
>         ...

Aha!  Good.  That proves my point!  :)
The server is sending back semantic information allowing the client to
correct the syntax of the input.  (Yes, it's also sending back the
corrected syntax, but that's secondary.)

That's what I'm suggesting for jCIFS.  Assume the object is a file, but
send the request to the server and find out what it really is.  If it's
a directory then add the slash to the URL.  Very much like what you've
shown above. 

On the other hand, if you are handed a URL with no trailing slash and 
you then connect to the server and find out that it references a
directory, you can throw an exception  (which I think you said jCIFS
does do).  The exception can then be caught by the application code
and the slash added.  It happens at a higher level in the code, but
it's still the same thing.

Chris -)-----

Samba Team -- http://www.samba.org/     -)-----   Christopher R. Hertel
jCIFS Team -- http://jcifs.samba.org/   -)-----   ubiqx development, uninq.
ubiqx Team -- http://www.ubiqx.org/     -)-----   crh at ubiqx.mn.org
OnLineBook -- http://ubiqx.org/cifs/    -)-----   crh at ubiqx.org

More information about the jcifs mailing list