Skip to content

Commit 624280f

Browse files
committed
Made entity caching only support non binary content.
1 parent 3e96034 commit 624280f

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

source/Superluminal-RESTfulAPI-Tests/RESTfulAPIClientTest.class.st

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,26 @@ RESTfulAPIClientTest >> testQueryDoNotStoreResponseInCache [
476476
withMessageText: 'Cannot complete the request'
477477
]
478478

479+
{ #category : 'tests - QUERY' }
480+
RESTfulAPIClientTest >> testQueryEntityMustBeString [
481+
482+
self configureHttpClientToRespondWith: ( ( self jsonOkResponseWith: #( 1 2 3 ) )
483+
addCachingDirective: 'Max-Age=60';
484+
yourself ).
485+
486+
self
487+
should: [
488+
apiClient
489+
query: ( ZnEntity bytes:
490+
( ByteArray streamContents: [ :out | 32 timesRepeat: [ out nextPut: 255 atRandom ] ] ) )
491+
at: self location
492+
accepting: 'application/json;version=1.0.0' asMediaType
493+
withSuccessfulResponseDo: [ :responseContents | self fail ]
494+
]
495+
raise: HTTPClientError badRequest
496+
withMessageText: 'Entity to cache can''t be binary'
497+
]
498+
479499
{ #category : 'tests - QUERY' }
480500
RESTfulAPIClientTest >> testQueryIgnoreETagsWhenDoNotStoreCachingPolicyIsInPlace [
481501

source/Superluminal-RESTfulAPI/ExpiringCacheKeyBuilder.class.st

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ ExpiringCacheKeyBuilder >> build [
4848
{ #category : 'configuring' }
4949
ExpiringCacheKeyBuilder >> entity: entity [
5050

51+
( entity hasContentType and: [ entity contentType isBinary ] ) ifTrue: [
52+
HTTPClientError badRequest signal: 'Entity to cache can''t be binary' ].
53+
5154
entity contents ifNotEmpty: [ :contents | parameters at: #entity put: contents asString ]
5255
]
5356

0 commit comments

Comments
 (0)