|
Class: HTTPService
Object
|
+--HTTPService
|
+--ComancheService
|
+--Demos::HelloWorldService
|
+--Demos::WebSlideShow
|
+--HTTPFileService
|
+--HTTPLinkForwardWithEMailService
|
+--HTTPPluggableActionService
|
+--HTTPRestService
|
+--HTTPScriptProviderService
|
+--HTTPSelectorService
|
+--HTTPTentativeObjectService
|
+--SeasideService
- Package:
- stx:goodies/webServer
- Category:
- Net-Communication-HTTP-Services
- Version:
- rev:
1.229
date: 2024/03/05 21:24:27
- user: cg
- file: HTTPService.st directory: goodies/webServer
- module: stx stc-classLibrary: webServer
This is an abstract class, providing common helpers for all http-Services.
An HTTPService registers itself towards an HTTPServer (under a linkName),
and then gets requests forwarded from that HTTPServer.
Registration is by the top linkName - all requests for URLS below that name
are sent as messages to the service
(a service may also be registered via multiple linkNames).
I have two subclasses (which are also abstract):
HTTPActionService - which gets the full request as argument to its #process: method.
and
HTTPSelectorService - which dispatches to individual processing methods, depending on
the URLs next name component.
To aid in programming threadsafe services there is a class named HTTPServiceRequestContext
that provides an interface to be inherited from. This allows you to store variables on a
per request basis. For every request an instance of your subclass is created where the
instance variable request is set. Before passing through the service, initialize is called
where you can do your own initialization of your variables. This enables you to have request
dependent state. At the end of the request release is called.
Redefine the class method requestContextClass: for your service that returns your subclass
of HTTPServiceRequestContext.
See more info in these subclasses and their concrete example subclasses.
copyrightCOPYRIGHT (c) 2003 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.
browser interface
-
iconInBrowserSymbol
-
can be redefined for a private icon in the browser (for me and my subclasses).
The returned symbol must be a selector of the ToolbarIconLibrary.
class access
-
defaultReplyPresenterClass
-
-
requestContextClass
-
returns a class which will be create a new instance for every new request
the class have to be inherits from HTTPServiceRequestContext and contains the
request as an instance variable
class initialization
-
initialize
-
self initialize
defaults
-
canChangeReplyPresenter
-
answer true, if the service can change its reply presenter.
Subclasses may redefine this
-
defaultAllowRobots
-
-
defaultPassword
-
-
defaultRealm
-
-
defaultServerPort
-
-
defaultUser
-
-
linkName
-
return the default path (with slash).
Either redefine this method in a concrete subclass,
or redefine the sender, #linkNames (for multiple default linkNames).
** This method must be redefined in concrete classes (subclassResponsibility) **
-
linkNames
-
return a collection of default paths (with initial slashes).
Either redefine this in a concrete service, or #linkName (for a single default linkName).
** This method must be redefined in concrete classes (subclassResponsibility) **
-
noRealmBehavior
-
specify how to behave if the service was registered without a realm.
Possible return values:
all - allow access for all
nobody - deny access for all
localHostOnly - only allow for local host
localNetOnly - only allow for local network
default is all here and localHostOnly in MaintenanceService
instance creation
-
new
-
(comment from inherited method)
return an instance of myself without indexed variables
queries
-
isAbstract
-
if true, its not listed in wellknownServices and cannot be instantiated
-
isBrowserStartable
-
return true, if this is an application class,
which can be started from the browser
-
isStartableWithStart
-
return true, if this is an application class,
which can be started via #start
queries-service
-
addToWellKnownClasses
-
-
compiledIntoSettingsDialog
-
-
isThreadSafe
-
return true, if this service is threadSafe.
If not, only a single request is passed to the service at any time (by the HTTPServer);
if it is, multiple requests may be served by multiple threads in parallel.
-
settingsApplicationClass
-
a SettingsApplication class - or nil (used in the settings dialog if non-nil)
-
shownInSettingsDialog
-
registration
-
availableServiceClassNames
-
must update known classNames
Usage example(s):
self availableServiceClassNames
|
-
availableServiceClasses
-
self availableServiceClasses
-
loadedServiceClassNames
-
self loadedServiceClassNames
-
loadedServiceClassNamesWithFilter: aBlock
-
self loadedServiceClassNames
-
registerServiceIn: anHTTPServer
-
create a new service and register it as service reachable via the default servicePath on anHTTPServer
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
registerServiceOn: anHTTPServer
-
create a new service and register it as service reachable via the default servicePath on anHTTPServer
-
registerServiceOnPort: aPortNr
-
ensure that a webserver is running on aPortNr,
create a new service and register it as service reachable via the default servicePath
inside that webserver
-
unRegisterServiceIn: anHTTPServer
-
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
unRegisterServiceOn: anHTTPServer
-
unregister a service class on anHTTPServer
-
wellknownServiceClassNames
-
automagically generated - see #availableServiceClassNames.
resources
-
classResources
-
if not already loaded, get the classes resourcePack and return it
Usage example(s):
Procware::ProcWareService classResources
|
-
flushAllClassResources
-
-
flushClassResources
-
-
update: something with: aParameter from: changedObject
-
flush resources on language changes
startup
-
start
-
start the service on the default web server (8080) if there is one.
If there is none, ask if it should be started
-
startOn: httpServer
-
start(restart) the service on the given server.
accessing
-
allowRobots
-
true, if robots are allowed to enter this service
-
allowRobots: something
-
true, if robots are allowed to enter this service
-
allowWebSockets: something
-
-
contextForRequest: aRequest
-
-
httpServer
-
-
httpServer: something
-
-
lastRequest
-
-
noRealmBehavior: something
-
-
realm: something
-
set the realm - if non-nil, the request must be authorized
-
replyPresenter
-
return the class name of the replyPresenter,
the setter does switch between class name and instance (from old settings files)
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
replyPresenter: something
-
this has become obsolete, use #replyPresenterClass
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
replyPresenterClass
-
-
replyPresenterClass: aClassOrNil
-
-
replyPresenterForRequest: aRequest
-
-
requestContextForRequest: aRequest
-
-
visibleInHomePage
-
-
visibleInHomePage: something
-
authorization
-
addUser: aUser password: aPassword toRealm: aRealm
-
this message is sent if a user is added to a realm or changed.
Subclasses may redefine this
-
allowedAuthMethods
-
answer a collection of allowed authenticatation method names
-
allowedAuthenticationClasses
-
answer a collection of authenticators that may be used to authenticate
-
authenticationDataForUser: userName inRealm: aRealm
-
by default, forward to my server. However, individual services might
redefine this to define their own, private user-groups
-
authorizeRequest: aRequest
-
ensure, that a request is authorized to use this service.
This is the case, if it is authenticated for a user in the services realm
-
canAuthenticate: aRequest with: authenticator
-
is it allowed to authenticate using authenticator?
by default, forward to my server. However, individual services might
redefine this to be more or less strict.
-
noRealmBehavior
-
specify how to behave if the service was registered without a realm
-
supportsRealm: aRealm
-
by default, answer true, if users are registered for a realm.
Redefine this, if you use your own user database.
-
usersForRealm: aRealm
-
by default, forward to my server. However, individual services might
redefine this to define their own, private user-groups
helpers
-
adjustReponseHeaderForWebSocketRequest: aRequest
-
empty -> no support of any extension at all,
be explicit by sending the empty extensions line
instead of sending no extensions line
initialize & release
-
initialize
-
(comment from inherited method)
just to ignore initialize to objects which do not need it
-
postStopServing
-
this is sent after the HTTPServer stops to accept connections
Can be redefined in subclasses for doing any actions
-
preStartServing
-
this is sent before the HTTPServer starts to accept connections
Can be redefined in subclasses for doing any actions
-
shutdown
-
invoked when deregistered, after the last request can be served.
Can be redefined in subclasses to perform service specific cleanup actions.
-
startup
-
invoked when registered, before the first request can be served.
Can be redefined in subclasses to perform service specific startup actions.
maintenance html presentation
-
commonChangeFromRequest: aRequest
-
extracts parameter from an html-maintenance post-request
(common parameters, valid for all services)
-
commonInputFieldsForRequest: aRequest change: change
-
generates the html-fragment for maintenance form
(common fields, valid for all services)
-
specificChangeFromRequest: aRequest
-
extracts parameter from an html-maintenance post-request;
service specific - to be redefined by services.
-
specificInputFieldsForRequest: aRequest
-
generates the html-fragment for the maintenance form;
service specific - to be redefined by services.
printing
-
nameInSettingsTable
-
redefined in ComancheService, which adds the module-name
-
printOn: aStream
-
(comment from inherited method)
append a user printed representation of the receiver to aStream.
The format is suitable for a human - not meant to be read back.
The default here is to output the receiver's class name.
BUT: this method is heavily redefined for objects which
can print prettier.
queries
-
acceptsWebSocket: webSocket request: aRequest
-
subclasses should redefine this, to check for a concrete webSocket request
to be valid and allowed at this time
-
allowRobotsPaths
-
cg: who was it to name this method just the opposite of what it really does ?
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
allowWebSockets
-
subclasses should redefine this, to return true
(or initialize allowWebSockets to true),
if it is generally prepared for webSockets.
However, it still has to check incoming individual requests with acceptsWebSocket:
-
debugErrors
-
answer true, if we run in debug mode,
i.e., a debugger should be opened on error
-
forbiddenRobotsPaths
-
return the disallowed paths for robots
-
isRunning
-
answer true if service is running
-
overallNumberOfRequests
-
the overall number of incoming requests
queries-service
-
isAllowedInMaintenanceMode
-
return true, if this service is also allowed while the server is in maintenance mode
-
isFileService
-
anwser true, if this services serves files
-
isHTTPService
-
anwser true
-
linkName
-
return the pathName of this service (incl. slash);
i.e. if '/Bla' is returned, the service is reached as http://hostname:port/Bla.
If this service is registered under multiple names, only the first is returned here.
If the linkname was not explicitely assigned (via linkName: or linkNames:),
then the service's class is asked for a default linkNames
-
linkName: aString
-
set the pathName of this service (incl. slash);
i.e. if '/Bla' is passed as argument, the service will be reached as http://hostname:port/Bla.
If this is never called, then the service class is asked for a default name
-
linkNames
-
return the relative pathName of this service; i.e. if
'Bla' is returned, the service is reached as http://hostname:port/Bla.
If the linkname was not explicitely assigned (via linkName: or linkNames:),
then the service's class is asked for a default linkNames
-
linkNames: aLinkNameCollection
-
set the names, under this service may be reaches;
e.g. if you set linkNames to #('/xxx' '/yyy') this service may be reached as both
'http://hostname:port/xxx' and 'http://hostname:port/yyy'.
If this is never called, then the service class is asked for a default name
-
nameInSettingsDialog
-
-
realm
-
return the realm - if non nil, the request must be authorized
-
settingsApplicationClass
-
answer a class that represents an Application used to configure
the service's settings - or nil (used in the settings dialog if non-nil)
-
skipInstvarIndexInDeepCopy: anIndex
-
answer true, if the instance variable at: anIndex
should not be copied on #deepCopy
-
suppressInHomePage
-
answer true, if the service should not be visible in the server's home page
registration
-
addAuthentificationTo: aServer
-
-
addRequiredForeignServicesTo: aServer
-
hook to allow for a service to register other required services.
Typically, these are required file services for bitmaps or icons.
Redefined in subclasses.
-
addStandardFileServicesTo: aServer
-
many services need the files in data/sampleServerDir/files.
This method registers a corresponding file service
-
isRegistered
-
answer true, if this service is registered with a server
-
registerServiceIn: aServer
-
register myself as service on a single HTTPServer
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
registerServiceOn: anHTTPServer
-
register myself as service on a single HTTPServer
-
registerServiceOnPort: aPortNr
-
ensure that a webserver is running on aPortNr,
create a new service and register me as service reachable via my linkNames (the default servicePaths)
inside that webserver
-
release
-
(comment from inherited method)
remove all references to objects that may refer to self.
Subclasses may redefine this method but should do a 'super release'.
-
removeRequiredForeignServicesFrom: aServer
-
-
unRegister
-
unregister myself from my HTTPServer
-
unRegisterServiceIn: anHTTPServer
-
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
unRegisterServiceOn: anHTTPServer
-
unregister myself from an HTTPServer
request handling
-
_process: aRequest
-
internal processing method: care for synchronization
-
process: aRequest
-
all the work is done in this method.
Any service has to implement this method
** This method must be redefined in concrete classes (subclassResponsibility) **
-
processWebSocketRequest: aRequest
-
tell the client that the webSocket request has been accepted
to do this send a response header with a matching hash in #Sec-WebSocket-Accept
-
startServingWebSocket: webSocket
-
to be redefined in subclasses (services) which do handle webSockets;
close here, in case it was not redefined
** This method must be redefined in concrete classes (subclassResponsibility) **
settings persistency
-
elementDescriptorFor: anAspect
-
support for persistency:
answer the elements to be made persistent with an ObjectCoder
-
settingSelectors
-
answer the selectors that are used to configure a service - i.e. those which are
saved in the webServer-settings file.
Usage example(s):
HTTPService new settingSelectors
|
NoRealmBehavior
|