JavaScriptHttpDispatcher

Overview

The JavaScriptHttpDispatcher class provides very easy way to add the Remoting SDK for JavaScript support to a Remoting SDK server application.

The main difference between the base HttpFileDispatcher class and the JavaScriptHttpDispatcher class is that latter allows to serve requests to the Remoting SDK for JavaScript core files by providing file content stored in the RemObjects.SDK.Server assembly resources.

In the simplest case all what is needed to add support for the Remoting SDK for JavaScript clients to a Remoting SDK server application is to place JavaScriptHttpDispatcher component next to the ServerChannel component and to point dispatcher's Server property to the server channel (obviously only Http and SuperHttp-based server channels are supported). See the Calling Remoting SDK Servers from JavaScript article for more details.

Location

 

constructor

Creates a new instance of the JavaScriptHttpDispatcher class.

 

constructor

 

JavaScriptHttpDispatcher()

 

Sub New

Activate    (declared in ExtendedHttpDispatcher)

 

method Activate

 

void Activate()

 

Sub Activate

add_Request    (declared in HttpFileDispatcher)

 

method add_Request(value: RequestEventHandler)

 

void add_Request(RequestEventHandler value)

 

Sub add_Request(value As RequestEventHandler)

Parameters:

  • value:

CanHandlePath    (declared in ExtendedHttpDispatcher)

Checks if the provided relative HTTP request path can be processed by this dispatcher.

 

method CanHandlePath(path: String): Boolean

 

Boolean CanHandlePath(String path)

 

Function CanHandlePath(path As String) As Boolean

Parameters:

  • path:

Deactivate    (declared in ExtendedHttpDispatcher)

 

method Deactivate

 

void Deactivate()

 

Sub Deactivate

DefaultFile    (declared in HttpFileDispatcher)

Gets or sets a name(resource) of the file that will be sent back by default whenever a request comes in that doesn't specify a filename.

The default value is index.html.

 

property DefaultFile: String read write;

 

String DefaultFile { get; set; }

 

Property DefaultFile As String

Dispose  protected    (declared in ExtendedHttpDispatcher)

If the disposing parameter is set to true, this method unregisters this dispatcher instance from the server.

 

method Dispose(disposing: Boolean)

 

void Dispose(Boolean disposing)

 

Sub Dispose(disposing As Boolean)

Parameters:

  • disposing: If set to true, the current dispatcher instance will be unregistered from the server.

Folder    (declared in HttpFileDispatcher)

Gets or sets a path to the folder where server will try to find the requested file.

The default value is html.

 

property Folder: String read write;

 

String Folder { get; set; }

 

Property Folder As String

IsFileContainedInResource  protected

Returns true if requested file is contained in the assembly resources.

Extends the base method implementation by adding additional check for the RemObjectsSDK.js file.

 

method IsFileContainedInResource(fileName: String): Boolean

 

Boolean IsFileContainedInResource(String fileName)

 

Function IsFileContainedInResource(fileName As String) As Boolean

Parameters:

  • fileName: A file name to search in assembly resources.

MESSAGE_FORBIDDEN  protected    (declared in HttpFileDispatcher)

 

const MESSAGE_FORBIDDEN: String = "<font size=""7"">403 Forbidden</font>";

 

const String MESSAGE_FORBIDDEN = "<font size=""7"">403 Forbidden</font>"

 

Dim MESSAGE_FORBIDDEN As String = "<font size=""7"">403 Forbidden</font>"

MESSAGE_INTERNAL_ERROR  protected    (declared in HttpFileDispatcher)

 

const MESSAGE_INTERNAL_ERROR: String = "<font size=""7"">500 Server Error</font><br/>";

 

const String MESSAGE_INTERNAL_ERROR = "<font size=""7"">500 Server Error</font><br/>"

 

Dim MESSAGE_INTERNAL_ERROR As String = "<font size=""7"">500 Server Error</font><br/>"

MESSAGE_NOT_FOUND  protected    (declared in HttpFileDispatcher)

 

const MESSAGE_NOT_FOUND: String = "<font size=""7"">404 Requested Resource not Found</font>";

 

const String MESSAGE_NOT_FOUND = "<font size=""7"">404 Requested Resource not Found</font>"

 

Dim MESSAGE_NOT_FOUND As String = "<font size=""7"">404 Requested Resource not Found</font>"

MESSAGE_READ_ERROR  protected    (declared in HttpFileDispatcher)

 

const MESSAGE_READ_ERROR: String = "Resource could not be read:<br/>";

 

const String MESSAGE_READ_ERROR = "Resource could not be read:<br/>"

 

Dim MESSAGE_READ_ERROR As String = "Resource could not be read:<br/>"

NotifyDispose    (declared in ExtendedHttpDispatcher)

This method is called when the ExtendedDispatcherList instance where the current instance is registered is disposed.

 

method NotifyDispose

 

void NotifyDispose()

 

Sub NotifyDispose

OnRequest  protected    (declared in HttpFileDispatcher)

Triggers the Request event.

 

method OnRequest(e: RequestEventArgs)

 

void OnRequest(RequestEventArgs e)

 

Sub OnRequest(e As RequestEventArgs)

Parameters:

  • e: Request arguments that will be provided to the Request event handler.

Path    (declared in ExtendedHttpDispatcher)

Gets or sets the relative HTTP path requests that will be processed by the current HttpDispatcher instance.

Path should begin with "/".

 

property Path: String read write;

 

String Path { get; set; }

 

Property Path As String

Process    (declared in HttpFileDispatcher)

Processing incoming HTTP requests.

The priority of serving HTTP requests is:

Try to retrieve requested data via the Request event handler

Try to find requested file in the Folder folder (this step is skipped if the ServeFilesFromFolder property is set to false)

Try to find requested resource in the assembly resources

 

method Process(request: IHttpRequest; responseHeader: IHttpResponse; requestData: Stream; responseData: Stream)

 

void Process(IHttpRequest request, IHttpResponse responseHeader, Stream requestData, Stream responseData)

 

Sub Process(request As IHttpRequest, responseHeader As IHttpResponse, requestData As Stream, responseData As Stream)

Parameters:

  • request: HTTP request information like headers collection, HTTP method etc.
  • responseHeader: HTTP response headers. Can be used to provide custom HTTP headers.
  • requestData: HTTP request data. Can be used to extract additional request data if needed.
  • responseData: HTTP response data.

remove_Request    (declared in HttpFileDispatcher)

 

method remove_Request(value: RequestEventHandler)

 

void remove_Request(RequestEventHandler value)

 

Sub remove_Request(value As RequestEventHandler)

Parameters:

  • value:

Request    (declared in HttpFileDispatcher)

This event allows custom processing of incoming resource requests. It is raised prior to file-system access and resources collection traverse.

Main purpose of this event is to allow to serve HTTP requests to data that cannot be stored in the filesystem or server app's assemblies (like server workload info page).

 

event Request: RequestEventHandler;
delegate: method Request(sender: Object; e: RequestEventArgs)

 

delegate RequestEventHandler Request()
delegate: void Request(Object sender, RequestEventArgs e)

 

Event Request As RequestEventHandler
delegate: Sub Request(sender As Object, e As RequestEventArgs)

ResolveContentType  protected    (declared in HttpFileDispatcher)

Determines MIME content type according to the provided file extension.

This method extensively uses the extensions cache unitialized by the InitializeExtensionsCache method.

In case of cache miss this method tries to read content type from the Windows Registry and to add it to the extensions cache.

 

method ResolveContentType(fileName: String): String

 

String ResolveContentType(String fileName)

 

Function ResolveContentType(fileName As String) As String

Parameters:

  • fileName: A file name for which the content type should be resolved.

ResourceAssemblies  protected    (declared in HttpFileDispatcher)

Gets a set of assemblies where component will try to find a requested resource if it wasn't provided by the Request event handler or found in the Folder folder.

The devault value is the RemObjects.SDK.Server assemble, however this property is usually overriden in the HttpFileDispatcher descendants

 

property ResourceAssemblies: array of Assembly read;

 

Assembly[] ResourceAssemblies { get; }

 

Property ReadOnly ResourceAssemblies As array of Assembly

ServeFilesFromFolder    (declared in HttpFileDispatcher)

Gets or sets a flag indicating whether the current instance will try to find requested resource in the Folder folder.

Setting this property to false can significantly speed-up the request processing by avoiding direct file-system access.

The defaul value is true.

 

property ServeFilesFromFolder: Boolean read write;

 

Boolean ServeFilesFromFolder { get; set; }

 

Property ServeFilesFromFolder As Boolean

Server    (declared in ExtendedHttpDispatcher)

The IHttpServer instance this dispatcher is registered in.

The ExtendedHttpDispatcher instance is automatically registered in the provided IHttpServer instance's extended dispatchers list when this property is set.

 

property Server: IHttpServer read write;

 

IHttpServer Server { get; set; }

 

Property Server As IHttpServer

ServeROJavaScript

Defines if dispatcher should serve all HTTP requests to the RemObjectsSDK.js using the file contained in the RemObjects.SDK.Server assembly resources.

The default value of this property is true.

 

property ServeROJavaScript: Boolean read write;

 

Boolean ServeROJavaScript { get; set; }

 

Property ServeROJavaScript As Boolean

 

MESSAGE_FORBIDDEN  protected    (declared in HttpFileDispatcher)

 

const MESSAGE_FORBIDDEN: String = "<font size=""7"">403 Forbidden</font>";

 

const String MESSAGE_FORBIDDEN = "<font size=""7"">403 Forbidden</font>"

 

Dim MESSAGE_FORBIDDEN As String = "<font size=""7"">403 Forbidden</font>"

MESSAGE_INTERNAL_ERROR  protected    (declared in HttpFileDispatcher)

 

const MESSAGE_INTERNAL_ERROR: String = "<font size=""7"">500 Server Error</font><br/>";

 

const String MESSAGE_INTERNAL_ERROR = "<font size=""7"">500 Server Error</font><br/>"

 

Dim MESSAGE_INTERNAL_ERROR As String = "<font size=""7"">500 Server Error</font><br/>"

MESSAGE_NOT_FOUND  protected    (declared in HttpFileDispatcher)

 

const MESSAGE_NOT_FOUND: String = "<font size=""7"">404 Requested Resource not Found</font>";

 

const String MESSAGE_NOT_FOUND = "<font size=""7"">404 Requested Resource not Found</font>"

 

Dim MESSAGE_NOT_FOUND As String = "<font size=""7"">404 Requested Resource not Found</font>"

MESSAGE_READ_ERROR  protected    (declared in HttpFileDispatcher)

 

const MESSAGE_READ_ERROR: String = "Resource could not be read:<br/>";

 

const String MESSAGE_READ_ERROR = "Resource could not be read:<br/>"

 

Dim MESSAGE_READ_ERROR As String = "Resource could not be read:<br/>"

 

DefaultFile    (declared in HttpFileDispatcher)

Gets or sets a name(resource) of the file that will be sent back by default whenever a request comes in that doesn't specify a filename.

The default value is index.html.

 

property DefaultFile: String read write;

 

String DefaultFile { get; set; }

 

Property DefaultFile As String

Folder    (declared in HttpFileDispatcher)

Gets or sets a path to the folder where server will try to find the requested file.

The default value is html.

 

property Folder: String read write;

 

String Folder { get; set; }

 

Property Folder As String

Path    (declared in ExtendedHttpDispatcher)

Gets or sets the relative HTTP path requests that will be processed by the current HttpDispatcher instance.

Path should begin with "/".

 

property Path: String read write;

 

String Path { get; set; }

 

Property Path As String

ResourceAssemblies  protected    (declared in HttpFileDispatcher)

Gets a set of assemblies where component will try to find a requested resource if it wasn't provided by the Request event handler or found in the Folder folder.

The devault value is the RemObjects.SDK.Server assemble, however this property is usually overriden in the HttpFileDispatcher descendants

 

property ResourceAssemblies: array of Assembly read;

 

Assembly[] ResourceAssemblies { get; }

 

Property ReadOnly ResourceAssemblies As array of Assembly

ServeFilesFromFolder    (declared in HttpFileDispatcher)

Gets or sets a flag indicating whether the current instance will try to find requested resource in the Folder folder.

Setting this property to false can significantly speed-up the request processing by avoiding direct file-system access.

The defaul value is true.

 

property ServeFilesFromFolder: Boolean read write;

 

Boolean ServeFilesFromFolder { get; set; }

 

Property ServeFilesFromFolder As Boolean

Server    (declared in ExtendedHttpDispatcher)

The IHttpServer instance this dispatcher is registered in.

The ExtendedHttpDispatcher instance is automatically registered in the provided IHttpServer instance's extended dispatchers list when this property is set.

 

property Server: IHttpServer read write;

 

IHttpServer Server { get; set; }

 

Property Server As IHttpServer

ServeROJavaScript

Defines if dispatcher should serve all HTTP requests to the RemObjectsSDK.js using the file contained in the RemObjects.SDK.Server assembly resources.

The default value of this property is true.

 

property ServeROJavaScript: Boolean read write;

 

Boolean ServeROJavaScript { get; set; }

 

Property ServeROJavaScript As Boolean

 

constructor

Creates a new instance of the JavaScriptHttpDispatcher class.

 

constructor

 

JavaScriptHttpDispatcher()

 

Sub New

Activate    (declared in ExtendedHttpDispatcher)

 

method Activate

 

void Activate()

 

Sub Activate

add_Request    (declared in HttpFileDispatcher)

 

method add_Request(value: RequestEventHandler)

 

void add_Request(RequestEventHandler value)

 

Sub add_Request(value As RequestEventHandler)

Parameters:

  • value:

CanHandlePath    (declared in ExtendedHttpDispatcher)

Checks if the provided relative HTTP request path can be processed by this dispatcher.

 

method CanHandlePath(path: String): Boolean

 

Boolean CanHandlePath(String path)

 

Function CanHandlePath(path As String) As Boolean

Parameters:

  • path:

Deactivate    (declared in ExtendedHttpDispatcher)

 

method Deactivate

 

void Deactivate()

 

Sub Deactivate

Dispose  protected    (declared in ExtendedHttpDispatcher)

If the disposing parameter is set to true, this method unregisters this dispatcher instance from the server.

 

method Dispose(disposing: Boolean)

 

void Dispose(Boolean disposing)

 

Sub Dispose(disposing As Boolean)

Parameters:

  • disposing: If set to true, the current dispatcher instance will be unregistered from the server.

IsFileContainedInResource  protected

Returns true if requested file is contained in the assembly resources.

Extends the base method implementation by adding additional check for the RemObjectsSDK.js file.

 

method IsFileContainedInResource(fileName: String): Boolean

 

Boolean IsFileContainedInResource(String fileName)

 

Function IsFileContainedInResource(fileName As String) As Boolean

Parameters:

  • fileName: A file name to search in assembly resources.

NotifyDispose    (declared in ExtendedHttpDispatcher)

This method is called when the ExtendedDispatcherList instance where the current instance is registered is disposed.

 

method NotifyDispose

 

void NotifyDispose()

 

Sub NotifyDispose

OnRequest  protected    (declared in HttpFileDispatcher)

Triggers the Request event.

 

method OnRequest(e: RequestEventArgs)

 

void OnRequest(RequestEventArgs e)

 

Sub OnRequest(e As RequestEventArgs)

Parameters:

  • e: Request arguments that will be provided to the Request event handler.

Process    (declared in HttpFileDispatcher)

Processing incoming HTTP requests.

The priority of serving HTTP requests is:

Try to retrieve requested data via the Request event handler

Try to find requested file in the Folder folder (this step is skipped if the ServeFilesFromFolder property is set to false)

Try to find requested resource in the assembly resources

 

method Process(request: IHttpRequest; responseHeader: IHttpResponse; requestData: Stream; responseData: Stream)

 

void Process(IHttpRequest request, IHttpResponse responseHeader, Stream requestData, Stream responseData)

 

Sub Process(request As IHttpRequest, responseHeader As IHttpResponse, requestData As Stream, responseData As Stream)

Parameters:

  • request: HTTP request information like headers collection, HTTP method etc.
  • responseHeader: HTTP response headers. Can be used to provide custom HTTP headers.
  • requestData: HTTP request data. Can be used to extract additional request data if needed.
  • responseData: HTTP response data.

remove_Request    (declared in HttpFileDispatcher)

 

method remove_Request(value: RequestEventHandler)

 

void remove_Request(RequestEventHandler value)

 

Sub remove_Request(value As RequestEventHandler)

Parameters:

  • value:

ResolveContentType  protected    (declared in HttpFileDispatcher)

Determines MIME content type according to the provided file extension.

This method extensively uses the extensions cache unitialized by the InitializeExtensionsCache method.

In case of cache miss this method tries to read content type from the Windows Registry and to add it to the extensions cache.

 

method ResolveContentType(fileName: String): String

 

String ResolveContentType(String fileName)

 

Function ResolveContentType(fileName As String) As String

Parameters:

  • fileName: A file name for which the content type should be resolved.

 

Request    (declared in HttpFileDispatcher)

This event allows custom processing of incoming resource requests. It is raised prior to file-system access and resources collection traverse.

Main purpose of this event is to allow to serve HTTP requests to data that cannot be stored in the filesystem or server app's assemblies (like server workload info page).

 

event Request: RequestEventHandler;
delegate: method Request(sender: Object; e: RequestEventArgs)

 

delegate RequestEventHandler Request()
delegate: void Request(Object sender, RequestEventArgs e)

 

Event Request As RequestEventHandler
delegate: Sub Request(sender As Object, e As RequestEventArgs)

See Also

  • Calling Remoting SDK Servers from JavaScript
  • HttpFileDispatcher
  • Remoting SDK for JavaScript
  • JavaScriptHttpDispatcher Class:
    • Data Abstract
    • Remoting SDK