diff --git a/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegate.class/instance/actualFilenameFor..st b/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegate.class/instance/actualFilenameFor..st index c58b9e33..86db9631 100644 --- a/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegate.class/instance/actualFilenameFor..st +++ b/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegate.class/instance/actualFilenameFor..st @@ -3,7 +3,7 @@ actualFilenameFor: uri | subElements subDir entry | (uri isEmpty and: [ self prefix isEmpty ]) ifTrue: [ ^ self indexFileIn: self directory ]. (self prefix isEmpty or: [ uri isEmpty not and: [ uri pathSegments beginsWith: self prefix ] ]) ifFalse: [ ^ nil ]. - subElements := (uri pathSegments allButFirst: self prefix size) reject: [ :each | each = #/ ]. + subElements := (uri pathSegments allButFirst: self prefix size) reject: [ :each | each = $/ ]. subDir := subElements allButLast inject: self directory into: [ :parent :sub | | file | (file := parent / sub) exists ifTrue: [ file ] diff --git a/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegate.class/instance/directoryRedirectFor..st b/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegate.class/instance/directoryRedirectFor..st index bb13b209..ba5e2298 100644 --- a/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegate.class/instance/directoryRedirectFor..st +++ b/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegate.class/instance/directoryRedirectFor..st @@ -1,5 +1,5 @@ private directoryRedirectFor: uri | directoryUri | - directoryUri := uri copy addPathSegment: #/. + directoryUri := uri copy addPathSegment: $/. ^ ZnResponse redirect: directoryUri \ No newline at end of file diff --git a/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegateTest.class/instance/indexHtml.st b/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegateTest.class/instance/indexHtml.st new file mode 100644 index 00000000..4921894b --- /dev/null +++ b/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegateTest.class/instance/indexHtml.st @@ -0,0 +1,7 @@ +private +indexHtml + ^ ' +Index +

Hi, i''m the index page

+ +' \ No newline at end of file diff --git a/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegateTest.class/instance/setUp.st b/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegateTest.class/instance/setUp.st index 3d824ac1..6e450530 100644 --- a/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegateTest.class/instance/setUp.st +++ b/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegateTest.class/instance/setUp.st @@ -12,4 +12,8 @@ setUp ZnFileSystemUtils writeStreamFor: 'wide.html' do: [ :stream | - stream nextPutAll: self wideHtml ]. \ No newline at end of file + stream nextPutAll: self wideHtml ]. + ZnFileSystemUtils + writeStreamFor: 'index.html' + do: [ :stream | + stream nextPutAll: self indexHtml ]. \ No newline at end of file diff --git a/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegateTest.class/instance/tearDown.st b/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegateTest.class/instance/tearDown.st index 911acc84..085e0ada 100644 --- a/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegateTest.class/instance/tearDown.st +++ b/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegateTest.class/instance/tearDown.st @@ -3,6 +3,7 @@ tearDown ZnFileSystemUtils deleteIfExists: 'small.html'; deleteIfExists: 'large.html'; - deleteIfExists: 'wide.html'. + deleteIfExists: 'wide.html'; + deleteIfExists: 'index.html'. super tearDown \ No newline at end of file diff --git a/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegateTest.class/instance/testRedirect.st b/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegateTest.class/instance/testRedirect.st new file mode 100644 index 00000000..7ad498d4 --- /dev/null +++ b/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegateTest.class/instance/testRedirect.st @@ -0,0 +1,16 @@ +tests +testRedirect + self + withServerDo: [ :server | + | client | + (client := ZnClient new) + beOneShot; + url: server localUrl; + addPath: #('local-files'); + get. + self assert: client isSuccess. + self assert: client response contentType equals: ZnMimeType textHtml. + self assert: client contents equals: self indexHtml. + self assert: (ZnUtils parseHttpDate: (client response headers at: 'Modification-Date')) equals: (ZnFileSystemUtils modificationTimeFor: 'index.html') asUTC. + self assert: (ZnUtils parseHttpDate: (client response headers at: 'Expires')) > (DateAndTime now + 10 days). + self assert: (client response headers at: 'Cache-Control') equals: (server delegate maxAgeFor: ZnMimeType textHtml) ] \ No newline at end of file diff --git a/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegateTest.class/properties.json b/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegateTest.class/properties.json index e1ec4434..c2109756 100644 --- a/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegateTest.class/properties.json +++ b/repository/Zinc-HTTP-Examples.package/ZnStaticFileServerDelegateTest.class/properties.json @@ -1,5 +1,5 @@ { - "commentStamp" : "SvenVanCaekenberghe 12/8/2019 14:06", + "commentStamp" : "", "super" : "TestCase", "category" : "Zinc-HTTP-Examples", "classinstvars" : [ ],