Skip to content

Commit

Permalink
Improve expiration headers handling for GS64
Browse files Browse the repository at this point in the history
Improve RESTfulAPIClient put methods to always return a response object
  • Loading branch information
gcotelli committed Feb 27, 2024
1 parent 710dfe2 commit 53cec0f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion source/Superluminal-RESTfulAPI/ExpiringResource.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ ExpiringResource >> withExpirationDo: ifPresentBlock ifNone: noneBlock [
^ [
ifPresentBlock value:
( self expirationDateApplyingCacheControlDirectivesIfNone: [ self expires ] ) ]
on: NotFound , SubscriptOutOfBounds
on: NotFound , SubscriptOutOfBounds , CollectionIsEmpty
do: [ :ex | ex return: noneBlock value ]
]

Expand Down
14 changes: 7 additions & 7 deletions source/Superluminal-RESTfulAPI/RESTfulAPIClient.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -268,13 +268,13 @@ RESTfulAPIClient >> postAt: aLocation configuredBy: aRequestBuildingBlock withSu
{ #category : 'private - inkoving' }
RESTfulAPIClient >> processPutResponse: response at: aLocation whenSuccessfulDo: aBlock [

response isSuccess
then: [
expiringCache clearResourceAt: aLocation.
^ response isNoContent
then: [ response ]
otherwise: [ aBlock value: ( self tryToCacheContentsOf: response basedOn: aLocation ) ]
].
response isSuccess then: [
expiringCache clearResourceAt: aLocation.
[
aBlock value:
(self tryToCacheContentsOf: response basedOn: aLocation) ] unless:
response isNoContent.
^ response ].

^ self signalCannotCompleteUpdateErrorBasedOn: response
]
Expand Down

0 comments on commit 53cec0f

Please sign in to comment.