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.69 date: 2017/02/22 18:08:57
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:'https://www.cacert.org'

instance creation
o  classForScheme: schemeString

o  fromString: aString
check fragment and search part
usage example(s):
     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#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
hack for MSDOS-type files, with a volume
usage example(s):
     self oldFromURLString:'checkout.stt'.   
     self fromURLString:'checkout.stt'.      

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

o  method: methodString path: pathString

o  new

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

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

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

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

o  fragmentPart: aString

o  host
return the host

o  host: aString
set the host

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

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 value of the instance variable 'rest' (automatically generated)

o  rest: aString
set the value of the instance variable 'rest' (automatically generated)

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

comparing
o  = anURL

o  copyWithoutFragmentPart

o  copyWithoutOtherPart

o  hash

o  postCopy
super postCopy.

conversion
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    

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  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  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.1.0.0; WebServer 1.663 at exept.de:8081; Mon, 04 Aug 2025 11:48:37 GMT