|
Class: URL
Object
|
+--URL
- Package:
- stx:libhtml
- Category:
- Net-Communication-Support
- Version:
- rev:
1.98
date: 2024/02/12 17:14:11
- user: cg
- file: URL.st directory: libhtml
- module: stx stc-classLibrary: libhtml
(for now) only a holder for the parse URL info.
Will takeover more functionality in the near future.
Please Notice:
this class is more or less obsoleted by URI, which provides better support
for multiple transports, passwords etc.
However, a lot of old code still uses URL, and also Squeak has an URL as well.
So this remains here, although this has a slight duplicate-code odeur.
Please use URI if possible.
copyrightCOPYRIGHT (c) 1997 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
Compatibility-Squeak
-
schemeNameForString: urlString
-
self schemeNameForString:'ftp://www.cacert.org/foo'
self schemeNameForString:'http://www.cacert.org'
self schemeNameForString:'https://www.cacert.org'
instance creation
-
classForScheme: schemeString
-
return a scheme specific class (possibly a subclass of me)
-
fromString: aString
-
check fragment and search part
Usage example(s):
URL fromString: '#foo'.
URL fromString: '#foo?bla'.
URL fromString: '#foo?bla=bbb'.
URL fromString: '?bla'.
URL fromString: '?bla=bbb'.
URL fromString: 'http://www'.
URL fromString: 'http://www/dir/file.html'.
URL fromString: 'http://www:10080/dir/file.html'.
URL fromString: 'http://www:10080/dir/file.html?x=100'.
URL fromString: 'http://www:10080/dir/file.html?a=1&b=2&c=3'.
URL fromString: 'http://www:10080/dir/file.html#section'.
URL fromString: 'ftp://ftp/pub/smalltalk'.
URL fromString: 'ftp://ftp:21/pub/smalltalk'.
URL fromString: 'ftp://user@ftp:21/pub/smalltalk'.
URL fromString: 'ftp://user@ftp/pub/smalltalk'.
URL fromString: 'ftp://user:passwd@ftp:21/pub/smalltalk'.
URL fromString: 'news:fj.lang.smalltalk'.
URL fromString: '/dir/file.html'.
URL fromString: 'file.html'.
URL fromString: 'file://D:\foo\bar\baz'.
|
-
fromURLString: aStringIn
-
this only cares for the scheme-transparent parts:
scheme, host, port, path
It does not split the path into local-anchor / search-args / post-args.
TODO: after parsing the scheme, let scheme-specific class parse the rest
(to allow for MailToUrl, LdapUrl, etc.)
Usage example(s):
self oldFromURLString:'checkout.stt'.
self fromURLString:'checkout.stt'.
|
-
method: methodString host: hostString path: pathString
-
-
method: methodString host: hostString port: portNumber path: pathString
-
-
method: methodString path: pathString
-
(URL method:'file' path:'/tmp') asString
(URL method:'http' path:'/tmp') asString
(URL method:'http' host:'www.exept.de' path:'/tmp') asString
(URL method:'http' host:'www.exept.de' port:8080 path:'/tmp') asString
-
new
-
(comment from inherited method)
return an instance of myself without indexed variables
-
scheme: schemeString host: hostString port: portNumber path: pathString
-
Modified (format): / 27-05-2019 / 12:24:53 / Claus Gittinger
-
scheme: schemeString host: hostString port: portNumber path: pathString hostIsIPv6: hostIsIPv6Boolean
-
-
scheme: schemeString path: pathString
-
self scheme:'http' path:'foo/bar/baz'
self scheme:'http' host:'www.exept.de' port:80 path:'foo/bar/baz'
self fromString:'http://www.exept.de/foo/bar/baz&foo=1&bar=2'
utilities
-
constructPath: path1 with: path2
-
trim path tail (file name).
Compatibility-Squeak
-
authority
-
-
fullPath
-
-
retrieveContents
-
squeak compatibility
-
retrieveContentsAccept: mimeType
-
squeak compatibility
-
retrieveContentsArgs: args
-
squeak compatibility
-
retrieveContentsArgs: args accept: mimeType
-
squeak compatibility
** This method must be redefined in concrete classes (subclassResponsibility) **
-
withoutFragment
-
what does it do ?
accessing
-
anchor
-
return the anchor in the fragment part;
that is the name of the local anchor within the document.
May be nil or empty
Usage example(s):
'http://www.exept.de/index.html#anc' asURL anchor -> 'anc'
'http://www.exept.de/index.html#anc?foo' asURL anchor -> 'anc'
'http://www.exept.de/index.html?foo' asURL anchor -> nil
'http://www.exept.de/index.html?foo=1&bar=2' asURL anchor -> nil
|
-
anchor: aString
-
set the anchor in the fragment part;
that is the name of the local anchor within the document.
May be nil or empty
Usage example(s):
('http://www.exept.de/index.html#anc' asURL anchor:'bbb') asString -> 'http://www.exept.de/index.html#bbb'
('http://www.exept.de/index.html#anc?foo' asURL anchor:'bbb') asString -> 'http://www.exept.de/index.html#bbb?foo'
('http://www.exept.de/index.html#anc?foo=1&bar=2' asURL anchor:'bbb') asString -> 'http://www.exept.de/index.html#bbb?foo=1&bar=2'
('http://www.exept.de/index.html?foo' asURL anchor:'bbb') asString -> 'http://www.exept.de/index.html#bbb'
('http://www.exept.de/index.html?foo=1&bar=2' asURL anchor:'bbb') asString
|
-
baseName
-
the basename of the file part
Usage example(s):
'http://www.exept.de/index.html' asURL path
'http://www.exept.de/index.html' asURL baseName
'file:///index.html' asURL path
'file:///index.html' asURL baseName
'http://www.exept.de/index.html#anc' asURL baseName
'http://www.exept.de/index.html#anc?foo' asURL baseName
|
-
file
-
return the file/path part.
Same as path for compatibility
-
file: aString
-
set the file/path part.
Same as path: for compatibility
-
fragmentPart
-
set the anchor and any additional parameters make the fragment part;
May be nil or empty
Usage example(s):
'http://www.exept.de/index.html#anc' asURL fragmentPart
'http://www.exept.de/index.html#anc?foo' asURL fragmentPart
'http://www.exept.de/index.html#anc?foo' asURL parameters
'http://www.exept.de/index.html?foo=1&bar=2' asURL parameters
'http://www.exept.de/index.html#anc?foo=1&bar=2' asURL parameters
|
-
fragmentPart: aStringOrNil
-
set the anchor and any additional parameters (the fragment part);
May be nil or empty
Usage example(s):
('http://www.exept.de/index.html#anc' asURL fragmentPart:'bbb') asString
('http://www.exept.de/index.html#anc?foo' asURL fragmentPart:'bbb') asString
|
-
host
-
return the host
-
host: aString
-
set the host
-
hostIsIPv6
-
return true, if the hostname is actually an ipv6 host address
-
hostIsIPv6: aBoolean
-
true, if the hostname is actually an ipv6 host address
-
method
-
return the access scheme (http, https, ftp, etc.).
Same as scheme for compatibility
-
method: aString
-
set the access scheme (http, https, ftp, etc.).
Same as scheme: for compatibility
-
otherPart
-
anything after the path (i.e. local anchor plus parameters)
-
parameters
-
extract parameters from the otherpart;
parses the '?foo=fooVal&bar=barval...' part of the URL (after the plain href),
and returns an orderedDictionary containing the key-value pairs
Usage example(s):
|url|
url := URL fromString:'https://www.exept.de/foo?p1=bla&p2=bla bla'.
url otherPart.
url parameters.
|
Usage example(s):
|url|
url := URL fromString:'https://www.exept.de/foo#anchor?p1=bla&p2=bla bla'.
url otherPart.
url parameters.
|
-
parameters: aDictionary
-
set parameters in otherpart;
generates '?foo=fooVal&bar=barval...'
Usage example(s):
|url|
url := URL fromString:'https://www.exept.de/foo'.
url asString.
url otherPart.
url parameters:(OrderedDictionary withKeysAndValues:#('p1' '111' 'p2' 222)).
url asString.
|
Usage example(s):
|url|
url := URL fromString:'https://www.exept.de/foo?p1=bla&p2=bla bla'.
url asString.
url otherPart.
url parameters:(OrderedDictionary withKeysAndValues:#('p1' '111' 'p2' 222)).
url asString.
|
Usage example(s):
|url|
url := URL fromString:'https://www.exept.de/foo#anchor?p1=bla&p2=bla bla'.
url asString.
url parameters:(OrderedDictionary withKeysAndValues:#('p1' '111' 'p2' 222)).
url asString.
|
-
path
-
return the file/path part.
Same as file for compatibility
-
path: aString
-
set the file/path part.
Same as file: for compatibility
-
port
-
return the port; may be nil
-
port: anInteger
-
set the port; may be nil
-
rest
-
return the rest after the method and host part (i.e. file + parameters)
-
scheme
-
return the access scheme (http, https, ftp, etc.).
Same as method for compatibility
-
scheme: aString
-
set the access scheme (http, https, ftp, etc.).
Same as method: for compatibility
-
scheme: schemeString host: hostString port: portNumber path: pathString
-
-
scheme: schemeString host: hostString port: portNumber path: pathString hostIsIPv6: hostIsIPv6Boolean
-
comparing
-
= anURL
-
Modified (format): / 29-06-2018 / 12:40:45 / Claus Gittinger
-
copyWithoutFragmentPart
-
-
copyWithoutOtherPart
-
-
hash
-
(comment from inherited method)
return an Integer useful as a hash key for the receiver.
This hash should return same values for objects with same
contents (i.e. use this to hash on structure)
conversion
-
asURI
-
return an URI-object from myself
Usage example(s):
'http://www.exept.de/index.html' asURL asURI
'https://www.exept.de/index.html' asURL asURI
'http://www.exept.de:80/index.html' asURL asURI
'ftp://www.exept.de/index.html' asURL asURI
|
-
asURL
-
return an URL-object from myself - that's me.
Usage example(s):
'http://www.exept.de:80/index.html' asURL host
'http://www.exept.de:80/index.html' asURL port
'http://www.exept.de:80/index.html' asURL method
'http://www.exept.de:80/index.html' asURL path
|
-
asUrl
-
Same as asURL - for Squeak/Pharo compatibility.
copying-private
-
postCopy
-
super postCopy.
parsing
-
parseFromString: urlString
-
parse URL contained in a string and set my inst vars
printing & storing
-
displayOn: aGCOrStream
-
return a string to display the receiver - for display in Inspector
-
printOn: aStream
-
take care, used by #fullRequestString and #urlPrintString
-
storeOn: aStream
-
'https://foo' asURL storeString => '''https://foo'' asURL'
'https://foo:8080' asURL storeString => '''https://foo:8080'' asURL'
'https://www.exept.de:8080/foo/bar' asURL storeString => '''https://www.exept.de:8080/foo/bar'' asURL'
-
urlPrintString
-
the printString of the full url (incl. method, host and port)
private
-
clearFragmentPart
-
-
clearOtherPart
-
Modified (format): / 27-09-2022 / 22:34:19 / Stefan_Vogel
-
flag
-
-
hasFragmentPartBitMask
-
-
hasPostDataBitMask
-
-
hasSearchPartBitMask
-
-
initialize
-
(comment from inherited method)
just to ignore initialize to objects which do not need it
-
setOtherPart: aString flag: anInteger
-
Modified (format): / 27-09-2022 / 22:35:34 / Stefan_Vogel
queries
-
canCache
-
-
fullRequestString
-
-
hasFragmentPart
-
-
hasFragmentPart: aBoolean
-
self new hasFragmentPart
(self new hasFragmentPart:true) hasFragmentPart
-
hasPostData
-
-
hasPostData: aBoolean
-
-
hasSearchPart
-
-
hasSearchPart: aBoolean
-
Modified (format): / 27-05-2019 / 12:30:07 / Claus Gittinger
-
isFileScheme
-
-
isFragmentOnly
-
-
isHostRelativePath
-
-
isRelativePath
-
-
isValidMethod: aMethod
-
mhmh - is this a good idea (isn't it the task of a url-user to decide, which
methods it supports).
The URL does not really know...
-
newsGroup
-
If the receiver is an nntp url, return the news group; otherwise, return nil.
-
postData
-
-
postData: aString
-
-
requestString
-
everything but the host & scheme (i.e. path+options alone, as in an HTTP requests header line)
-
searchPart
-
-
searchPart: aString
-
testing
-
isHttpsUrl
-
-
isURL
-
(comment from inherited method)
Return true if the receiver is a url.
Note: Do not override in any class except URL.
utilities
-
/ aString
-
filename compatibility protocol:
A a new instance with aString concatenated to my path.
We simply append aString to the end of the path.
Look at construct for a more enhanced implementation.
Usage example(s):
'http://www.exept.de/start' asURL / 'bla'
'http://www.exept.de/start/' asURL / 'bla'
'http://www.exept.de' asURL / 'bla'
|
-
construct: anUrlOrString
-
filename compatibility protocol:
return a URL with a path which is the concatenation
of my path and anUrlOrString.
If anUrlOrString is a URL and has another method or host than the receiver,
it is returned plain.
Also, if anUrlOrString is either an URL representing an absolute path.
I.e. this method can be used to compute an html document's anchor's target URL
Usage example(s):
(URL fromString: 'http://www/dir/file.html') construct: (URL fromString: 'subdir/image.gif').
(URL fromString: 'http://www/dir1/file.html') construct: (URL fromString: '/dir2/image.gif').
(URL fromString: 'http://www/dir1/file.html') construct: (URL fromString: '~kyasu/').
(URL fromString: 'http://www/dir/file.html') construct: (URL fromString: '#introduction').
(URL fromString: 'http://www/dir/file.html') construct: (URL fromString: '/cgi-bin/perl.pl&dest=/other').
(URL fromString: 'http://www/dir/file.html') construct: (URL fromString: 'http:/cgi-bin/perl.pl&dest=/other').
(URL fromString: 'http://www-s2.rsl.crl.fujixerox.co.jp/~kyasu/') construct: (URL fromString: 'http://arrow').
(URL fromString: 'gopher://www.com') construct: (URL fromString: '//www.com:70/ParcBenchMain').
(URL fromString: 'http://www/some.html') construct: (URL fromString: 'http://www/').
(URL fromString: '../tmp/table.html') construct: (URL fromString: 'kyasu.gif').
|
-
constructString: anUrlOrString
-
filename compatibility protocol
Usage example(s):
(URL fromString: 'http://www/dir/') constructString:'subdir/image.gif'.
|
-
directory
-
filename compatibility protocol:
return a URL which represents the receiver's directoy
Usage example(s):
'http://www.exept.de:8080/foo/bar/baz.txt' asURL directory
'file:///foo/bar/baz.txt' asURL directory
|
-
pathBasename
-
answer the baseName of my path as a string.
eg. for '/part1/part2/part3.suffix' this is 'part3.suffix'
Usage example(s):
'http://www.exept.de:8080/foo/bar/baz.txt' asURL pathBasename
'file:///foo/bar/baz.txt' asURL pathBasename
|
-
pathSuffix
-
answer the suffix of my path as a string.
eg. for '/part1/part2/part3.suffix' this is 'suffix'
Usage example(s):
'http://www.exept.de:8080/foo/bar/baz.txt' asURL pathSuffix
'file:///foo/bar/baz.txt' asURL pathSuffix
|
-
pathWithoutSuffix
-
answer the baseName of my path as a string.
eg. for 'http://host/part1/part2/part3.suffix' this is '/part1/part2/part3'
Usage example(s):
'http://www.exept.de:8080/foo/bar/baz.txt' asURL pathWithoutSuffix
'file:///foo/bar/baz.txt' asURL pathWithoutSuffix
|
|