From 51d6654f69f28c666450b2c03a49db190edc5f34 Mon Sep 17 00:00:00 2001 From: Johan Brichau Date: Sun, 24 Dec 2023 10:58:32 +0100 Subject: [PATCH] Some more code style improvements --- .../instance/requestAddressFor..st | 7 +++--- .../instance/requestBodyFor..st | 18 ++++++++------- .../instance/requestFieldsFor..st | 23 ++++++++++--------- .../instance/requestHeadersFor..st | 8 ++++--- .../instance/requestUrlFor..st | 22 +++++++++--------- .../instance/requestVersionFor..st | 1 + 6 files changed, 43 insertions(+), 36 deletions(-) diff --git a/repository/Seaside-Zinc-Core.package/ZnZincServerAdaptor.class/instance/requestAddressFor..st b/repository/Seaside-Zinc-Core.package/ZnZincServerAdaptor.class/instance/requestAddressFor..st index f99db6941..4356959e0 100644 --- a/repository/Seaside-Zinc-Core.package/ZnZincServerAdaptor.class/instance/requestAddressFor..st +++ b/repository/Seaside-Zinc-Core.package/ZnZincServerAdaptor.class/instance/requestAddressFor..st @@ -1,5 +1,6 @@ converting-request requestAddressFor: aZincRequest - ^ aZincRequest headers - at: ZnConstants remoteAddressHeader - ifAbsent: [ nil ] \ No newline at end of file + + ^ aZincRequest headers + at: ZnConstants remoteAddressHeader + ifAbsent: [ nil ] \ No newline at end of file diff --git a/repository/Seaside-Zinc-Core.package/ZnZincServerAdaptor.class/instance/requestBodyFor..st b/repository/Seaside-Zinc-Core.package/ZnZincServerAdaptor.class/instance/requestBodyFor..st index d13a9f4a7..82bde5ec5 100644 --- a/repository/Seaside-Zinc-Core.package/ZnZincServerAdaptor.class/instance/requestBodyFor..st +++ b/repository/Seaside-Zinc-Core.package/ZnZincServerAdaptor.class/instance/requestBodyFor..st @@ -1,12 +1,14 @@ converting-request requestBodyFor: aZincRequest - ^ (aZincRequest method ~= #TRACE - and: [ aZincRequest hasEntity - and: [ aZincRequest entity isEmpty not - and: [ (aZincRequest entity contentType matches: ZnMimeType applicationFormUrlEncoded) not - and: [ (aZincRequest entity contentType matches: ZnMimeType multiPartFormData) not ] ] ] ]) - ifTrue: [ + + ^ (aZincRequest method ~= #TRACE and: [ + aZincRequest hasEntity and: [ + aZincRequest entity isEmpty not and: [ + (aZincRequest entity contentType matches: + ZnMimeType applicationFormUrlEncoded) not and: [ + (aZincRequest entity contentType matches: + ZnMimeType multiPartFormData) not ] ] ] ]) + ifTrue: [ "Seaside wants to do its own text conversions" aZincRequest entity bytes asString ] - ifFalse: [ - String new ] \ No newline at end of file + ifFalse: [ '' ] \ No newline at end of file diff --git a/repository/Seaside-Zinc-Core.package/ZnZincServerAdaptor.class/instance/requestFieldsFor..st b/repository/Seaside-Zinc-Core.package/ZnZincServerAdaptor.class/instance/requestFieldsFor..st index a7bf7792b..bdb11f19b 100644 --- a/repository/Seaside-Zinc-Core.package/ZnZincServerAdaptor.class/instance/requestFieldsFor..st +++ b/repository/Seaside-Zinc-Core.package/ZnZincServerAdaptor.class/instance/requestFieldsFor..st @@ -1,18 +1,19 @@ converting-request requestFieldsFor: aZincRequest + | fields | fields := WARequestFields new. (aZincRequest method = #POST and: [ aZincRequest hasEntity ]) ifTrue: [ - (aZincRequest entity contentType matches: ZnMimeType applicationFormUrlEncoded) - ifTrue: [ - fields addAll: (aZincRequest entity class = ZnStreamingEntity - ifTrue: [ - ZnApplicationFormUrlEncodedEntity new - readFrom: aZincRequest entity stream; - fields ] - ifFalse: [ aZincRequest entity fields ]) ]. - (aZincRequest entity contentType matches: ZnMimeType multiPartFormData) - ifTrue: [ - fields addAll: (self convertMultipart: aZincRequest entity) ] ]. + (aZincRequest entity contentType matches: + ZnMimeType applicationFormUrlEncoded) ifTrue: [ + fields addAll: (aZincRequest entity class = ZnStreamingEntity + ifTrue: [ + ZnApplicationFormUrlEncodedEntity new + readFrom: aZincRequest entity stream; + fields ] + ifFalse: [ aZincRequest entity fields ]) ]. + (aZincRequest entity contentType matches: + ZnMimeType multiPartFormData) ifTrue: [ + fields addAll: (self convertMultipart: aZincRequest entity) ] ]. ^ fields \ No newline at end of file diff --git a/repository/Seaside-Zinc-Core.package/ZnZincServerAdaptor.class/instance/requestHeadersFor..st b/repository/Seaside-Zinc-Core.package/ZnZincServerAdaptor.class/instance/requestHeadersFor..st index a992e283c..0a61596a6 100644 --- a/repository/Seaside-Zinc-Core.package/ZnZincServerAdaptor.class/instance/requestHeadersFor..st +++ b/repository/Seaside-Zinc-Core.package/ZnZincServerAdaptor.class/instance/requestHeadersFor..st @@ -1,12 +1,14 @@ converting-request requestHeadersFor: aZincRequest + | fields | fields := Dictionary new. aZincRequest headersDo: [ :key :value | | keyLowercase combinedValue | keyLowercase := key asLowercase. - combinedValue := fields at: keyLowercase - ifPresent: [ :presentValue | presentValue , ',' , value ] - ifAbsent: [ value ]. + combinedValue := fields + at: keyLowercase + ifPresent: [ :presentValue | presentValue , ',' , value ] + ifAbsent: [ value ]. fields at: keyLowercase put: combinedValue ]. ^ fields \ No newline at end of file diff --git a/repository/Seaside-Zinc-Core.package/ZnZincServerAdaptor.class/instance/requestUrlFor..st b/repository/Seaside-Zinc-Core.package/ZnZincServerAdaptor.class/instance/requestUrlFor..st index 3aa2284dc..96abb195d 100644 --- a/repository/Seaside-Zinc-Core.package/ZnZincServerAdaptor.class/instance/requestUrlFor..st +++ b/repository/Seaside-Zinc-Core.package/ZnZincServerAdaptor.class/instance/requestUrlFor..st @@ -1,20 +1,20 @@ converting-request requestUrlFor: aZincRequest + | zincUrl seasideUrl | zincUrl := aZincRequest url. seasideUrl := WAUrl new - scheme: zincUrl schemeOrDefault greaseString; - host: zincUrl host; - port: zincUrl port; - fragment: zincUrl fragment. + scheme: zincUrl schemeOrDefault greaseString; + host: zincUrl host; + port: zincUrl port; + fragment: zincUrl fragment. zincUrl hasPath ifTrue: [ zincUrl isDirectoryPath - ifTrue: [ "last path segment is $/ or #/" - zincUrl pathSegments - "GemStone/S currently does not support #allButLastDo:" - allButLast do: [ :each | seasideUrl rawAddToPath: each ]. - seasideUrl slash: true ] + ifTrue: [ + "last path segment is $/ or #/" + zincUrl pathSegments allButLast do: [ :each | seasideUrl rawAddToPath: each ]. + "GemStone/S currently does not support #allButLastDo:" + seasideUrl slash: true ] ifFalse: [ seasideUrl rawAddAllToPath: zincUrl pathSegments ] ]. - zincUrl - queryDo: [ :key :value | seasideUrl addField: key value: value ]. + zincUrl queryDo: [ :key :value | seasideUrl addField: key value: value ]. ^ seasideUrl \ No newline at end of file diff --git a/repository/Seaside-Zinc-Core.package/ZnZincServerAdaptor.class/instance/requestVersionFor..st b/repository/Seaside-Zinc-Core.package/ZnZincServerAdaptor.class/instance/requestVersionFor..st index aa6fa1455..a7992dd8b 100644 --- a/repository/Seaside-Zinc-Core.package/ZnZincServerAdaptor.class/instance/requestVersionFor..st +++ b/repository/Seaside-Zinc-Core.package/ZnZincServerAdaptor.class/instance/requestVersionFor..st @@ -1,3 +1,4 @@ converting-request requestVersionFor: aZincRequest + ^ WAHttpVersion fromString: aZincRequest requestLine version \ No newline at end of file