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.85 date: 2019/06/28 07:25:25
user: cg
file: URL.st directory: libhtml
module: stx stc-classLibrary: libhtml
Author:
Claus Gittinger

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.


Related information:

    URI
    FtpURI
    HttpURI
    FileURI

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

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 raises an error - it must be redefined in concrete classes **

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

o  parameters: aDictionary
set parameters in otherpart;
generates '?foo=fooVal&bar=barval...'

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

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  urlPrintString
the printString of the full url (incl. method, host and port)

private
o  clearFragmentPart

o  clearOtherPart

o  flag

o  hasFragmentPartBitMask

o  hasPostDataBitMask

o  hasSearchPartBitMask

o  initialize

o  setOtherPart: aString flag: anInteger

queries
o  canCache

o  fullRequestString

o  hasFragmentPart

o  hasFragmentPart: aBoolean
aBoolean

usage example(s):

     self new hasFragmentPart 
     (self new hasFragmentPart:true) hasFragmentPart 

o  hasPostData

o  hasPostData: aBoolean
aBoolean

o  hasSearchPart

o  hasSearchPart: aBoolean
aBoolean

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

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.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Wed, 10 Aug 2022 12:01:47 GMT