home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

HTML 4.0 Sourcebook
(Publisher: John Wiley & Sons, Inc.)
Author(s): Ian S. Graham
ISBN: 0471257249
Publication Date: 04/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


Modes for File Transfers

The FTP protocol supports several modes for transferring files. The most important is image or binary mode, which makes a byte-by-byte copy of the file. This is the mode to use when transferring programs, compressed data, or image files. Also important is ASCII or text mode, which is designed for transferring plain, printable text files. This mode is useful because it “corrects” for the fact that PCs, Macintoshes, UNIX, and other operating systems use different characters to mark the end of a line of text. In particular, Macintoshes use the carriage-return character CR; UNIX computers use the line-feed character LF; and DOS/Windows computers use both CR and LF (often written CRLF). In ASCII mode, FTP automatically converts between these three end-of-line markers to ensure that the received file has the new line codes appropriate to the local system. You cannot use this mode to transfer programs, however, since programs and data files contain bytes with the same codes as CR or LF characters—under ASCII mode, these codes are converted into the new-line codes appropriate to the local system, thereby corrupting the content of binary files.

The FTP protocol has no knowledge of the data content of a file and must be told what mode to use in a file transfer. Thus, your WWW browser must have some way of determining the data type of a file being accessed via an ftp URL. Some browsers “guess” the type from the suffix of the filename, using a browser database that maps filename suffixes onto data types. This is not ideal, since the true type is only known by the author who constructed the URL and who created the resource referenced by the URL.


TIP: Troubleshooting FTP URLs

At times, an ftp URL request will fail. This may occur because the network is down or because the machine being accessed is overloaded with FTP requests and refuses your connection. Alternatively, the remote server may be configured to limit access to a restricted set of Internet sites. Web browsers are very terse when handling FTP connections and say very little when a connection fails. You can often diagnose the source of a problem by using an FTP program, independent of your Web browser. A stand alone FTP session provides more commentary on the state of the connection and will often explain why a connection cannot be made.


FTP Typecode Strings

Authors can use URL typecode strings to specify the desired transfer mode. For example, the following URL

ftp://ftp.mysite.edu/path/splunge.txt;type=a

indicates that the designated resource (the file splunge.txt) should be retrieved using ASCII mode. The special semicolon character is used to separate the end of the resource locator string from the type indicator. Other possible type indicators are type=i for image (binary) transfers and type=d for directory listings. Typecode strings are optional, the default being binary data transfers. Fragment identifiers, if used, must be placed after the typecode string—for example:

ftp://ftp.somesite.edu/path/goof.html;type=a#location


TIP: Problems with Typecode Strings?

Typecode strings are supported by Netscape Navigator 3.0 and Microsoft Internet Explorer 3, but not by some other browsers or by earlier versions these programs. These older browsers assume the typecode string to be part of the filename, and thus do not locate the resource. If your URLs use typecode strings, you may wish to warn users about this possible problem.


Gopher URLs

Gopher servers can be accessed via URLs in a manner that looks superficially similar to ftp or http URLs but that is, in fact, quite different. This is because Gopher resources are referenced using a combination of resource identifier codes and selector strings, and not directories and files. Resource identifiers are single-digit codes that specify the type of the Gopher resource—for example, that it is a text file, a directory, or a searchable index. The Gopher selector string is just a symbolic name associated with this resource. This can be a directory or file name, but can also be a redirection to a database search procedure or to a Telnet session. Sometimes the selector string has, as its first character, a duplicate of the single-character resource type identifier. This can lead to hair-pulling confusion, with resource identifiers appearing alone or in pairs, seemingly at random. Table 8.3 summarizes the Gopher resource identifier codes.


Table 8.3 Gopher Resource Identifier Codes

Code File or Resource Type
0 Text file
1 Directory
2 CSO name/phone book server
3 Error
4 Macintosh binhexed (*.hqx) file
5 Dos binary file of some type
6 UNIX uuencoded file
7 Full-text index search
8 Telnet session
9 Binary file

General Form of a Gopher URL

The general form for a basic Gopher URL is

gopher:// int.domain.nam:port/Tselector_string

where the port number is optional (the default value is 70), T is the Gopher type code from Table 6.3, and selector_string is the Gopher selector string. The root information of a Gopher server can be obtained by leaving out all type and selector string information. Thus, the root information of the Gopher server at mr.bean.org is available at:

gopher://mr.bean.org/

Hierarchical relationships are possible. For example:

gopher://mr.bean.org/1stuff

indicates that stuff behaves like a directory and will retrieve the Gopher contents of stuff, while the URL

gopher://mr.bean.org/7stuff/index

indicates access to the index search in the directory stuff. Accessing this URL would cause the browser to ask the user for query string information to be used in the search.

Query Strings for Searches

Search information is sent to the Gopher server by appending the search strings to the URL, separated from the URL by a question mark. Thus, to pass the strings tad, jill, and joanne to the Gopher search index noted in the previous section, the URL is:

gopher://mr.bean.org/7stuff/index?tad+jill+joanne


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.