Network-Url

Authorizer
The Authorizer does user authorization checking. Each instance of authorizer keeps track of the realm that it is authorizing for, and the table of authorized users. An authorizer can be asked to return the user name/symbol associated with a userID (which concatenates the username and password from the HTTP request) with the user: method.
encode:password:
Encode per RFC1421 of the username:password combination.
mapFrom:to:
Establish a mapping from a RFC 1421 key to a user.
mapName:password:to:
Insert/remove the encoding per RFC1421 of the username:password combination into/from the UserMap. DO NOT call this directly, use mapName:password:to: in your ServerAction class. Only it knows how to record the change on the disk!
realm
realm:
unauthorizedFor:
user:
Return the requesting user.
BrowserUrl
URLs that instruct a browser to do something.
hasContents
whether this URL can download contents to be displayed; if not, it fundamentally requires an outside application to deal with it. For example, mailto: and telnet: urls
FileUrl
This class models a file URL according to (somewhat) RFC1738, see http://www.w3.org/Addressing/rfc1738.txt
Here is the relevant part of the RFC:
3.10 FILES
The file URL scheme is used to designate files accessible on a
particular host computer. This scheme, unlike most other URL schemes,
does not designate a resource that is universally accessible over the
Internet.
A file URL takes the form:
file://<host>/<path>
where <host> is the fully qualified domain name of the system on
which the <path> is accessible, and <path> is a hierarchical
directory path of the form <directory>/<directory>/.../<name>.
For example, a VMS file
DISK$USER:[MY.NOTES]NOTE123456.TXT
might become
<URL:file://vms.host.edu/disk$user/my/notes/note12345.txt>
As a special case, <host> can be the string "localhost" or the empty
string; this is interpreted as `the machine from which the URL is
being interpreted'.
The file URL scheme is unusual in that it does not specify an
Internet protocol or access method for such files; as such, its
utility in network protocols between hosts is limited.
From the above we can conclude that the RFC says that the <path> part never starts or ends with a slash and is always absolute. If the last name can be a directory instead of a file is not specified clearly.
The path is stored as a SequenceableCollection of path parts.
Notes regarding non RFC features in this class:
- If the last path part is the empty string, then the FileUrl is referring to a directory. This is also shown with a trailing slash when converted to a String.
- The FileUrl has an attribute isAbsolute which signals if the path should be considered absolute or relative to the current directory. This distinction is not visible in the String representation of FileUrl, since the RFC does not have that.
- Fragment is supported (kept for historical reasons)
absoluteFromText:
copy
Be sure not to share the path with the copy.
default
Use the default local Squeak file directory.
directoryUrl
The path always has at least one element so this works.
fileName
Return the last part of the path,
most often a filename but can also be a directory.
firstPartIsDriveLetter
Return true if the first part of the path is a letter
followed by a $: like 'C:'
hasContents
whether this URL can download contents to be displayed; if not, it fundamentally requires an outside application to deal with it. For example, mailto: and telnet: urls
host
Return the host name, either 'localhost', '', or a fully qualified domain name.
host:
Set the host name, either 'localhost', '', or a fully qualified domain name.
host:pathParts:isAbsolute:
initializeFromPathString:
<aPathString> is a file path as a String.
We construct a path collection using various heuristics.
isAbsolute
Should the path be considered absolute to
the filesystem instead of relative to the default directory?
isAbsolute:
Set if the path should be considered absolute to
the filesystem instead of relative to the default directory.
path
Return an ordered collection of the path elements.
path:
Set the collection of path elements.
pathDirString
Path to directory as url, using slash as delimiter.
Filename is left out.
pathForDirectory
Path using local file system's pathname delimiter.
DOS paths with drive letters should not
be prepended with a delimiter even though
they are absolute. Filename is left out.
pathForFile
Path using local file system's delimiter. $\ or $:
pathParts:
pathParts:isAbsolute:
pathString
Path as it appears in a URL with $/ as delimiter.
printOn:
Return the FileUrl according to RFC1738 plus supporting fragments:
'file://<host>/<path>#<fragment>'
Note that <host> being '' is equivalent to 'localhost'.
Note: The pathString can not start with a leading $/
to indicate an 'absolute' file path.
This is not according to RFC1738 where the path should have
no leading or trailing slashes, and always
be considered absolute relative to the filesystem.
privateInitializeFromText:
Calculate host and path from a file URL in String format.
Some malformed formats are allowed and interpreted by guessing.
privateInitializeFromText:relativeTo:
<pathString> should be a filesystem path.
This url is adjusted to be aUrl + the path.
retrieveContents
return a MIMEObject with the object's contents, or nil if the object could not be retrieved
scheme
return a string with the scheme of this URL. For instance, HTTP
schemeName
return a lowercase string with the scheme of this URL. For instance, 'http'
FtpUrl
a reference to a file which may be downloaded by anonymous ftp .
TODO: use the username and password, if specified
asRepository
downloadUrl
Returns a http download url for the location defined by this url.
hasRemoteContents
Return true if the receiver describes some remotely accessible content.
Typically, this should only return if we could retrieve the contents
on an arbitrary place in the outside world using a standard browser.
In other words: If you can get to it from the next Internet Cafe,
return true, else return false.
pathString
retrieveContents
currently assumes directories end in /, and things that don't end in / are files. Also, doesn't handle errors real well....
GenericUrl
a URL type that can't be broken down in any systematic way. For example, mailto: and telnet: URLs. The part after the scheme name is stored available via the #locator message.
absoluteFromText:
locator
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
privateInitializeFromText:
privateInitializeFromText:relativeTo:
initialize from the given string, as a relative URL. aString will have had the scheme name removed, if it was present to begin with. If it was, then the scheme name was the same as the receiver's scheme name
scheme
return a string with the scheme of this URL. For instance, HTTP
schemeName
return a lowercase string with the scheme of this URL. For instance, 'http'
schemeName:locator:
HierarchicalUrl
A URL which has a hierarchical encoding. For instance, http and ftp URLs are hierarchical.
authority
copy
Be sure not to share the path with the copy
directoryUrl
The path always has at least one element so this works.
fileName
Return the last part of the path,
most often a filename but does not need to be.
fullPath
hasContents
most of these do....
isAbsolute
password
http://user:pword@foo.com' asUrl password
path
return a collection of the decoded path elements, as strings
path:
Set the collection of path elements.
port
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
privateInitializeFromText:
privateInitializeFromText:relativeTo:
initialize from the given string, as a relative URL. aString will have had the scheme name removed, if it was present to begin with. If it was, then the scheme name was the same as the receiver's scheme name
privateParsePath:relativeTo:
query
return the query, the part after any ?. Any %XY's have already been decoded. If there wasno query part, nil is returned (it is possible to also have an empty query
scheme
return a string with the scheme of this URL. For instance, HTTP
schemeName
return a lowercase string with the scheme of this URL. For instance, 'http'
schemeName:authority:path:query:
initialize a new instance
username
http://user:pword@foo.com' asUrl username
HttpUrl
A URL that can be accessed via the Hypertext Transfer Protocol (HTTP), ie, a standard Web URL
realm = the name of the security realm that has been discovered for this URL. Look it up in Passwords.
Passwords = a Dictionary of (realm -> encoded user&password)
TODO: use the username and password, if specified
asRepository
askNamePassword
Authorization is required by the host site. Ask the user for a userName and password. Encode them and store under this realm. Return false if the user wants to give up.
checkAuthorization:retry:
authorization failed if webDocument is a String
hasRemoteContents
Return true if the receiver describes some remotely accessible content.
Typically, this should only return if we could retrieve the contents
on an arbitrary place in the outside world using a standard browser.
In other words: If you can get to it from the next Internet Cafe,
return true, else return false.
loadRemoteObjects
Load a remote image segment and extract the root objects.
Check if the remote file is a zip archive.
normalizeContents:
postFormArgs:
postMultipartFormArgs:
privateInitializeFromText:relativeTo:
initialize from the given string, as a relative URL. aString will have had the scheme name removed, if it was present to begin with. If it was, then the scheme name was the same as the receiver's scheme name
realm
retrieveContents
return a MIMEObject with the object's contents, or nil if the object could not be retrieved
retrieveContentsAccept:
retrieveContentsArgs:
From http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
The Accept request-header field can be used to specify certain media types which are acceptable for the response.
Accept = 'Accept' ':'
#( media-range [ accept-params ] )
media-range = ( '*/*'
| ( type '/' '*' )
| ( type '/' subtype )
) *( ';' parameter )
accept-params = ';' 'q' '=' qvalue *( accept-extension )
accept-extension = ';' token [ '=' ( token | quoted-string ) ]
The asterisk *' character is used to group media types into ranges, with '*/*' indicating all media types and 'type/*' indicating
all subtypes of that type. Each media-range MAY be followed by one or more accept-params, beginning with the 'q' parameter for
indicating a relative quality factor. Quality factors allow the user or user agent to indicate the relative degree of preference for
that media-range, using the qvalue scale from 0 to 1
retrieveContentsArgs:accept:
shutDown
MIMEHeaderValue
I contain the value portion of a MIME-compatible header.
I must be only initialized with the value and not the field name. E.g. in processing
Subject: This is the subject
the MIMEHeaderValue should be given only 'This is the subject'
For traditional non-MIME headers, the complete value returned for mainValue and paramaters returns an empty collection.
For MIME headers, both mainValue and parameters are used.
asHeaderValue
forField:fromString:
fromMIMEHeader:
fromTraditionalHeader:
mainValue
mainValue:
parameterAt:put:
parameters
parameters:
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
MailMessage
I represent an Internet mail or news message.
text - the raw text of my message
body - the body of my message, as a MIMEDocument
fields - a dictionary mapping lowercased field names into collections of MIMEHeaderValue's
parts - if I am a multipart message, then this is a cache of my parts
addAttachmentFrom:withName:
add an attachment, encoding with base64. aName is the option filename to encode
asSendableText
break lines in the given string into shorter lines
atomicParts
Answer all of the leaf parts of this message, including those of multipart included messages
attachmentSeparator
body
return just the body of the message
body:
change the body
bodyText
return the text of the body of the message
bodyTextFormatted
Answer a version of the text in my body suitable for display. This will parse multipart forms, decode HTML, and other such things
canonicalFields
Break long header fields and escape those containing high-ascii characters according to RFC2047
cc
cleanedHeader
Reply with a cleaned up version email header. First show fields people would normally want to see (in a regular order for easy browsing), and then any other fields not explictly excluded
containsViewableImage
date
Answer a date string for this message.
dateStampNow
decoderClass
empty
excerpt
Return a short excerpt of the text of the message
fieldNamed:ifAbsent:
return the value of the field with the specified name. If there is more than one field, then return the first one
fields
return the internal fields structure. This is private and subject to change!
fieldsFrom:do:
Invoke the given block with each of the header fields from the given stream. The block arguments are the field name and value. The streams position is left right after the empty line separating header and body.
fieldsNamed:ifAbsent:
return a list of all fields with the given name
fieldsNamed:separatedBy:
return all fields with the specified name, concatenated together with separationString between each element. Return an empty string if no fields with the specified name are present
format
Replace the text of this message with a formatted version.
formattedText
Answer a version of my text suitable for display. This cleans up the header, decodes HTML, and things like that
from
from:
Parse aString to initialize myself.
generateSeparator
hasFieldNamed:
headerFieldsNamed:do:
Evalue aBlock once for each header field which matches fieldName. The block is valued with one parameter, the value of the field
initialize
initialize as an empty message
makeMultipart
if I am not multipart already, then become a multipart message with one part
name
return a default name for this part, if any was specified. If not, return nil
omittedHeaderFields
parseParts
private -- parse the parts of the message and store them into a collection
parts
printOn:
For text parts with no filename show: 'text/plain: first line of text...'
for attachments/filenamed parts show: 'attachment: filename.ext'
readDateFrom:
Parse a date from the given stream and answer nil if the date can't be parsed. The date may be in any of the following forms:
<day> <monthName> <year> (5 April 1982; 5-APR-82)
<monthName> <day> <year> (April 5, 1982)
<monthNumber> <day> <year> (4/5/82)
In addition, the date may be preceded by the day of the week and an optional comma, such as:
Tue, November 14, 1989
readStringLineFrom:
Read and answer the next line from the given stream. Consume the carriage return but do not append it to the string.
regenerateBodyFromParts
regenerate the message body from the multiple parts
regenerateText
regenerate the full text from the body and headers
removeFieldNamed:
remove all fields with the specified name
reportField:to:
Evaluate the given block with the field name a value in the given field. Do nothing if the field is malformed.
rewriteFields:append:
Rewrite header fields. The body is not modified.
Each field's key and value is reported to aBlock. The block's return value is the replacement for the entire header line. Nil means don't change the line, empty means delete it. After all fields are processed, evaluate appendBlock and append the result to the header.
save
save the part to a file
selfTest
For testing only: Check that this instance is well formed and makes sense
setField:to:
set a field. If any field of the specified name exists, it will be overwritten
setField:toString:
skipWeekdayName:
If the given stream starts with a weekday name or its abbreviation, advance the stream to the first alphaNumeric character following the weekday name.
subject
text
the full, unprocessed text of the message
time
timeFrom:
Parse the date and time (rfc822) and answer the result as the number of seconds
since the start of 1980.
to
viewBody
open a viewer on the body of this message
viewImageInBody
MailtoUrl
a URL specifying a mailing address; activating it triggers a mail-sender to start up, if one is present.
activate
Activate a Celeste window for the receiver
composeText
Answer the template for a new message.
A link to a hidden mail message. Clicking on it allows the message to be viewed or saved to disk.
actOnClickFor:
Subclasses may override to provide, eg, hot-spot actions
emphasizeScanner:
Subclasses may override to set, eg, font, color, etc
initialize:
mayActOnClick
Subclasses may override to provide, eg, hot-spot actions
message:
Url
A Uniform Resource Locator. It specifies the location of a document on the Internet. The base class is abstract; child classes break different types of URLs down in ways appropriate for that type.
absoluteFromFileNameOrUrlString:
absoluteFromText:
activate
spawn an external handler for this URL
asRepository
asText
asURI
asUrl
asUrlRelativeTo:
authority
combine:withRelative:
downloadUrl
fragment
hasContents
whether this URL can download contents to be displayed; if not, it fundamentally requires an outside application to deal with it. For example, mailto: and telnet: urls
hasRemoteContents
Return true if the receiver describes some remotely accessible content.
Typically, this should only return if we could retrieve the contents
on an arbitrary place in the outside world using a standard browser.
In other words: If you can get to it from the next Internet Cafe,
return true, else return false.
newFromRelativeText:
return a URL relative to the current one, given by aString. For instance, if self is 'http://host/dir/file', and aString is '/dir2/file2', then the return will be a Url for 'http://host/dir2/file2'
printOn:
Append to the argument, aStream, a sequence of characters that
identifies the receiver.
privateFragment:
privateInitializeFromText:
privateInitializeFromText:relativeTo:
initialize from the given string, as a relative URL. aString will have had the scheme name removed, if it was present to begin with. If it was, then the scheme name was the same as the receiver's scheme name
retrieveContents
return a MIMEObject with the object's contents, or nil if the object could not be retrieved
retrieveContentsForBrowser:
return a MIMEObject with the object's contents, or nil if the object could not be retrieved. Since aBrowser is specified, this could do browser specific things
scheme
return a string with the scheme of this URL. For instance, HTTP
schemeName
return a lowercase string with the scheme of this URL. For instance, 'http'
schemeNameForString:
toText
urlClassForScheme:
withFragment:
return a URL which is the same except that it has a different fragment
withoutFragment
return a URL which is identical to the receiver except that it has no fragment associated with it
UrlArgumentList
An UrlArgumentList is xxxxxxxxx.
Instance Variables
add:value:
argumentNamed:
associationsDo:
Evaluate aBlock for each of the receiver's elements (key/value
associations). If any non-association is within, the error is not caught now,
but later, when a key or value message is sent to it.
with:
with:with:
with:with:with: