Skip to content

Commit 0320e9c

Browse files
Merge pull request #393 from michaelJustin/376-wiki-docs-tdjdefaultwebcomponentteststestdefaultwebcomponent
Added some doc comments
2 parents 2cfede7 + d0ff6b0 commit 0320e9c

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

source/optional/djDefaultWebComponent.pas

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

test/unittests/djDefaultWebComponentTests.pas

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ procedure TdjDefaultWebComponentTests.TestUpload;
191191
finally
192192
Server.Free;
193193
end;
194-
195194
end;
196195

197196
end.

0 commit comments

Comments
 (0)