eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'URL':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: URL


Inheritance:

   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

Description:


(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.

copyright

COPYRIGHT (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.

Class protocol:

Compatibility-Squeak
o  schemeNameForString: urlString
self schemeNameForString:'ftp://www.cacert.org/foo'
self schemeNameForString:'http://www.cacert.org'
self schemeNameForString:'https://www.cacert.org'

instance creation
o  classForScheme: schemeString
return a scheme specific class (possibly a subclass of me)

o  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'.

o  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'.      

o  method: methodString host: hostString path: pathString

o  method: methodString host: hostString port: portNumber path: pathString

o  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

o  new
(comment from inherited method)
return an instance of myself without indexed variables

o  scheme: schemeString host: hostString port: portNumber path: pathString
Modified (format): / 27-05-2019 / 12:24:53 / Claus Gittinger

o  scheme: schemeString host: hostString port: portNumber path: pathString hostIsIPv6: hostIsIPv6Boolean

o  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
o  constructPath: path1 with: path2
trim path tail (file name).


Instance protocol:

Compatibility-Squeak
o  authority

o  fullPath

o  retrieveContents
squeak compatibility

o  retrieveContentsAccept: mimeType
squeak compatibility

o  retrieveContentsArgs: args
squeak compatibility

o  retrieveContentsArgs: args accept: mimeType
squeak compatibility

** This method must be redefined in concrete classes (subclassResponsibility) **

o  withoutFragment
what does it do ?

accessing
o  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

o  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

o  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

o  file
return the file/path part.
Same as path for compatibility

o  file: aString
set the file/path part.
Same as path: for compatibility

o  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

o  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

o  host
return the host

o  host: aString
set the host

o  hostIsIPv6
return true, if the hostname is actually an ipv6 host address

o  hostIsIPv6: aBoolean
true, if the hostname is actually an ipv6 host address

o  method
return the access scheme (http, https, ftp, etc.).
Same as scheme for compatibility

o  method: aString
set the access scheme (http, https, ftp, etc.).
Same as scheme: for compatibility

o  otherPart
anything after the path (i.e. local anchor plus parameters)

o  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.

o  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.

o  path
return the file/path part.
Same as file for compatibility

o  path: aString
set the file/path part.
Same as file: for compatibility

o  port
return the port; may be nil

o  port: anInteger
set the port; may be nil

o  rest
return the rest after the method and host part (i.e. file + parameters)

o  scheme
return the access scheme (http, https, ftp, etc.).
Same as method for compatibility

o  scheme: aString
set the access scheme (http, https, ftp, etc.).
Same as method: for compatibility

o  scheme: schemeString host: hostString port: portNumber path: pathString

o  scheme: schemeString host: hostString port: portNumber path: pathString hostIsIPv6: hostIsIPv6Boolean

comparing
o  = anURL
Modified (format): / 29-06-2018 / 12:40:45 / Claus Gittinger

o  copyWithoutFragmentPart

o  copyWithoutOtherPart

o  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
o  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    

o  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    

o  asUrl
Same as asURL - for Squeak/Pharo compatibility.

copying-private
o  postCopy
super postCopy.

parsing
o  parseFromString: urlString
parse URL contained in a string and set my inst vars

printing & storing
o  displayOn: aGCOrStream
return a string to display the receiver - for display in Inspector

o  printOn: aStream
take care, used by #fullRequestString and #urlPrintString

o  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'

o  urlPrintString
the printString of the full url (incl. method, host and port)

private
o  clearFragmentPart

o  clearOtherPart
Modified (format): / 27-09-2022 / 22:34:19 / Stefan_Vogel

o  flag

o  hasFragmentPartBitMask

o  hasPostDataBitMask

o  hasSearchPartBitMask

o  initialize
(comment from inherited method)
just to ignore initialize to objects which do not need it

o  setOtherPart: aString flag: anInteger
Modified (format): / 27-09-2022 / 22:35:34 / Stefan_Vogel

queries
o  canCache

o  fullRequestString

o  hasFragmentPart

o  hasFragmentPart: aBoolean
self new hasFragmentPart
(self new hasFragmentPart:true) hasFragmentPart

o  hasPostData

o  hasPostData: aBoolean

o  hasSearchPart

o  hasSearchPart: aBoolean
Modified (format): / 27-05-2019 / 12:30:07 / Claus Gittinger

o  isFileScheme

o  isFragmentOnly

o  isHostRelativePath

o  isRelativePath

o  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...

o  newsGroup
If the receiver is an nntp url, return the news group; otherwise, return nil.

o  postData

o  postData: aString

o  requestString
everything but the host & scheme (i.e. path+options alone, as in an HTTP requests header line)

o  searchPart

o  searchPart: aString

testing
o  isHttpsUrl

o  isURL
(comment from inherited method)
Return true if the receiver is a url.
Note: Do not override in any class except URL.

utilities
o  / 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'

o  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').

o  constructString: anUrlOrString
filename compatibility protocol

Usage example(s):

       (URL fromString: 'http://www/dir/') constructString:'subdir/image.gif'.

o  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

o  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

o  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

o  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



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 04:25:24 GMT