|
@@ -18,24 +18,6 @@ ZnockBase class >> in: aZnock url: aZnUrl [
|
|
|
yourself
|
|
|
]
|
|
|
|
|
|
-{ #category : #public }
|
|
|
-ZnockBase >> badRequest: aZnRequest [
|
|
|
- aZnRequest
|
|
|
- ifNotNil: [ self response: (ZnResponse badRequest: aZnRequest) ]
|
|
|
- ifNil: [ self response: (ZnResponse statusLine: ZnStatusLine ok).
|
|
|
- builtClient customizeResponseBlock: [ :req :res |
|
|
|
- res customizeFrom: (ZnResponse badRequest: req) ] ]
|
|
|
-]
|
|
|
-
|
|
|
-{ #category : #public }
|
|
|
-ZnockBase >> badRequest: aZnRequest entity: aZnEntity [
|
|
|
- aZnRequest
|
|
|
- ifNotNil: [ self response: (ZnResponse badRequest: aZnRequest entity: aZnEntity) ]
|
|
|
- ifNil: [ self response: (ZnResponse statusLine: ZnStatusLine ok).
|
|
|
- builtClient customizeResponseBlock: [ :req :res |
|
|
|
- res customizeFrom: (ZnResponse badRequest: req entity: aZnEntity) ] ]
|
|
|
-]
|
|
|
-
|
|
|
{ #category : #accessing }
|
|
|
ZnockBase >> baseUrl [
|
|
|
^ baseUrl
|
|
@@ -46,11 +28,6 @@ ZnockBase >> baseUrl: aZnUrl [
|
|
|
baseUrl := aZnUrl
|
|
|
]
|
|
|
|
|
|
-{ #category : #building }
|
|
|
-ZnockBase >> clientSelectors [
|
|
|
- ^ #(addPath: addPathSegment: delete get head host: http https method: options patch path: port: post put username:password:)
|
|
|
-]
|
|
|
-
|
|
|
{ #category : #building }
|
|
|
ZnockBase >> closeState: aSymbol [
|
|
|
"self shouldBeImplemented."
|
|
@@ -58,14 +35,9 @@ ZnockBase >> closeState: aSymbol [
|
|
|
|
|
|
{ #category : #building }
|
|
|
ZnockBase >> doesNotUnderstand: aMessage [
|
|
|
- (self clientSelectors includes: aMessage selector) ifTrue: [
|
|
|
- self request.
|
|
|
- ^ aMessage sendTo: builtClient ].
|
|
|
- (self responseCreationSelectors includes: aMessage selector) ifTrue: [
|
|
|
- ^ self response: (aMessage sendTo: ZnResponse) ].
|
|
|
- (self responseSelectors includes: aMessage selector) ifTrue: [
|
|
|
- self response.
|
|
|
- ^ aMessage sendTo: builtClient response ].
|
|
|
+ self forwardedSelectors keysAndValuesDo: [ :handler :candidates |
|
|
|
+ (candidates includes: aMessage selector)
|
|
|
+ ifTrue: [ ^ self perform: handler with: aMessage ] ].
|
|
|
^ super doesNotUnderstand: aMessage
|
|
|
]
|
|
|
|
|
@@ -74,6 +46,56 @@ ZnockBase >> error: aString [
|
|
|
self response: (Error new messageText: aString; yourself)
|
|
|
]
|
|
|
|
|
|
+{ #category : #building }
|
|
|
+ZnockBase >> forwardedSelectors [
|
|
|
+ ^ {
|
|
|
+
|
|
|
+ #handleClientMessage: ->
|
|
|
+ #(addPath: addPathSegment: delete get head host: http https method: options patch path: port: post put #username:password:).
|
|
|
+
|
|
|
+ #handleResponseCreationMessage: ->
|
|
|
+ #(accepted noContent notModified ok: redirect: #redirect:entity: serverError: serverErrorWithEntity: statusCode: statusLine: unauthorized unauthorized: #unauthorized:entity:).
|
|
|
+
|
|
|
+ #handleResponseCreationFromRequestMessage: ->
|
|
|
+ #(#badRequest: badRequest:entity:).
|
|
|
+
|
|
|
+ #handleResponseMessage: ->
|
|
|
+ #(addCookie: entity: headers: resetEntity: setLocation: setWWWAuthenticate: statusLine:).
|
|
|
+
|
|
|
+ } asDictionary
|
|
|
+]
|
|
|
+
|
|
|
+{ #category : #building }
|
|
|
+ZnockBase >> handleClientMessage: aMessage [
|
|
|
+ self request.
|
|
|
+ ^ aMessage sendTo: builtClient
|
|
|
+]
|
|
|
+
|
|
|
+{ #category : #building }
|
|
|
+ZnockBase >> handleResponseCreationFromRequestMessage: aMessage [
|
|
|
+ aMessage argument ifNotNil: [ ^ self handleResponseCreationMessage: aMessage ].
|
|
|
+ self response: self newCleanResponse.
|
|
|
+ builtClient customizeResponseBlock: [ :req :res |
|
|
|
+ aMessage argument: req.
|
|
|
+ res customizeFrom: (aMessage sendTo: ZnResponse) ]
|
|
|
+]
|
|
|
+
|
|
|
+{ #category : #building }
|
|
|
+ZnockBase >> handleResponseCreationMessage: aMessage [
|
|
|
+ ^ self response: (aMessage sendTo: ZnResponse)
|
|
|
+]
|
|
|
+
|
|
|
+{ #category : #building }
|
|
|
+ZnockBase >> handleResponseMessage: aMessage [
|
|
|
+ self response.
|
|
|
+ ^ aMessage sendTo: builtClient response
|
|
|
+]
|
|
|
+
|
|
|
+{ #category : #building }
|
|
|
+ZnockBase >> newCleanResponse [
|
|
|
+ ^ ZnResponse statusLine: ZnStatusLine ok
|
|
|
+]
|
|
|
+
|
|
|
{ #category : #building }
|
|
|
ZnockBase >> openState: aSymbol [
|
|
|
aSymbol == #request ifTrue: [
|
|
@@ -116,16 +138,6 @@ ZnockBase >> response: response [
|
|
|
builtClient response: response
|
|
|
]
|
|
|
|
|
|
-{ #category : #building }
|
|
|
-ZnockBase >> responseCreationSelectors [
|
|
|
- ^ #(accepted noContent notModified ok: redirect: redirect:entity: serverError: serverErrorWithEntity: statusCode: statusLine: unauthorized unauthorized: unauthorized:entity:)
|
|
|
-]
|
|
|
-
|
|
|
-{ #category : #building }
|
|
|
-ZnockBase >> responseSelectors [
|
|
|
- ^ #(addCookie: entity: headers: resetEntity: setLocation: setWWWAuthenticate: statusLine:)
|
|
|
-]
|
|
|
-
|
|
|
{ #category : #building }
|
|
|
ZnockBase >> state: aSymbol [
|
|
|
state == aSymbol ifTrue: [ ^ self ].
|