@@ -41,16 +41,28 @@ interface
4141 { TdjDefaultWebComponent }
4242
4343 { *
44- * Web Component for static context.
44+ * Web Component for static content.
45+ *
46+ * After registration in a context, this web component will serve
47+ * requests for resources which have not been resolved by any other
48+ * registered web component, but exists in the file system.
49+ *
50+ * For a request to a resource
51+ * http://host:port/<context-root>/path/to/file.ext
52+ * the static file must exist at
53+ * <server-root>/webapps/<context-root>/path/to/file.ext
54+ *
55+ * If the file does not exist, a HTTP 404 error will be returned.
4556 *
4657 * @note This class is unsupported demonstration code.
58+ *
59+ * See TdjDefaultWebComponentTests for usage examples.
4760 *}
4861 TdjDefaultWebComponent = class (TdjWebComponent)
4962 private
5063 { $IFDEF DARAJA_LOGGING}
5164 Logger: ILogger;
5265 { $ENDIF DARAJA_LOGGING}
53-
5466 ContextPath: string;
5567 StaticResourcePath: string;
5668 procedure Trace (const S: string);
@@ -115,7 +127,6 @@ procedure TdjDefaultWebComponent.Validate;
115127 end
116128 else
117129 begin
118-
119130 { $IFDEF DARAJA_LOGGING}
120131 Logger.Warn(' Static content directory not found: ' + StaticResourcePath);
121132 { $ELSE}
@@ -168,11 +179,11 @@ procedure TdjDefaultWebComponent.Service(Context: TdjServerContext;
168179
169180 if FileExists(FileName) then
170181 begin
171-
172182 Response.ResponseNo := HTTP_OK;
173183 Response.ContentType :=
174184 Response.HTTPServer.MIMETable.GetFileMIMEType(FileName);
175185
186+ // TODO: why is HTML handled differently here?
176187 if Response.ContentType = ' text/html' then
177188 begin
178189 Response.ContentStream := TFileStream.Create(FileName, fmOpenRead or
0 commit comments