Skip to content

Commit

Permalink
Merge f4d8e60 into 8b1b37e
Browse files Browse the repository at this point in the history
  • Loading branch information
mtabacman committed Jan 2, 2020
2 parents 8b1b37e + f4d8e60 commit 39e5aa0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
14 changes: 14 additions & 0 deletions source/Hyperspace-Model-Tests/ZnResponseExtensionsTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ ZnResponseExtensionsTest >> testAddSeveralLinks [
ZnLink to: self amazonUrl }
]

{ #category : #tests }
ZnResponseExtensionsTest >> testCachingDirectives [

| response |

response := ZnResponse noContent.

response addCachingDirective: 'public'.
self assert: response cachingDirectives equals: #('public').

response addCachingDirective: 'Max-Age=60'.
self assert: response cachingDirectives equals: #('public' 'Max-Age=60')
]

{ #category : #tests }
ZnResponseExtensionsTest >> testEntityTag [

Expand Down
19 changes: 18 additions & 1 deletion source/Hyperspace-Model/ZnResponse.extension.st
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
Extension { #name : #ZnResponse }

{ #category : #'*Hyperspace-Model' }
ZnResponse >> addCachingDirective: aDirective [

self headers at: 'Cache-Control' add: aDirective
]

{ #category : #'*Hyperspace-Model' }
ZnResponse >> addLink: aLink [

self headers at: 'Link' add: aLink
]

{ #category : #'*Hyperspace-Model' }
ZnResponse >> cachingDirectives [

| directives |

directives := self headers at: 'Cache-Control' ifAbsent: [ ^ #() ].
^ directives isArray
ifTrue: [ directives ]
ifFalse: [ Array with: directives ]
]

{ #category : #'*Hyperspace-Model' }
ZnResponse >> entityTag [

Expand All @@ -18,7 +35,7 @@ ZnResponse >> links [
| links |

links := self headers at: 'Link' ifAbsent: [ ^ #() ].
^ links isCollection
^ links isArray
ifTrue: [ links ]
ifFalse: [ Array with: links ]
]
Expand Down

0 comments on commit 39e5aa0

Please sign in to comment.