Skip to content

Commit

Permalink
Some more code style improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrichau committed Dec 24, 2023
1 parent 245d8b7 commit 51d6654
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
converting-request
requestAddressFor: aZincRequest
^ aZincRequest headers
at: ZnConstants remoteAddressHeader
ifAbsent: [ nil ]

^ aZincRequest headers
at: ZnConstants remoteAddressHeader
ifAbsent: [ nil ]
Original file line number Diff line number Diff line change
@@ -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 ]
ifFalse: [ '' ]
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
converting-request
requestVersionFor: aZincRequest

^ WAHttpVersion fromString: aZincRequest requestLine version

0 comments on commit 51d6654

Please sign in to comment.