Skip to content

Commit

Permalink
Provide fixes similar to pharo-project/pharo#15253 for Zinc
Browse files Browse the repository at this point in the history
  • Loading branch information
astares committed Nov 7, 2023
1 parent f90402b commit 97afe55
Show file tree
Hide file tree
Showing 63 changed files with 81 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ isLegalCharacter: character

| code |
^ (code := character asciiValue) < 128
and: [ (inverse at: code + 1) notNil ]
and: [ (inverse at: code + 1) isNotNil ]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SystemOrganization addCategory: #'Zinc-Character-Encoding-Core'!
self packageOrganizer ensurePackage: #'Zinc-Character-Encoding-Core' withTags: #()!
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ handlePostRequest: request
partNamed: #file
ifNone: badRequest.
newImage := part entity.
(newImage notNil and: [ newImage contentType matches: 'image/*' asZnMimeType ])
(newImage isNotNil and: [ newImage contentType matches: 'image/*' asZnMimeType ])
ifFalse: badRequest.
[ self formForImageEntity: newImage ] on: Error do: badRequest.
image := newImage.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@ handleRequest: request
"Server delegate entry point"

| actualFilename |
(#(#GET #HEAD) includes: request method)
ifFalse: [ ^ ZnResponse methodNotAllowed: request ].
(#( #GET #HEAD ) includes: request method) ifFalse: [
^ ZnResponse methodNotAllowed: request ].
actualFilename := self actualFilenameFor: request uri.
^ actualFilename notNil
ifTrue: [
(self redirectNeededFor: request uri actualFilename: actualFilename)
ifTrue: [ self directoryRedirectFor: request uri ]
ifFalse: [ self responseForFile: actualFilename fromRequest: request ] ]
ifFalse: [ ZnResponse notFound: request uri ]
^ actualFilename
ifNotNil: [
(self
redirectNeededFor: request uri
actualFilename: actualFilename)
ifTrue: [ self directoryRedirectFor: request uri ]
ifFalse: [
self responseForFile: actualFilename fromRequest: request ] ]
ifNil: [ ZnResponse notFound: request uri ]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SystemOrganization addCategory: #'Zinc-HTTP-Examples'!
self packageOrganizer ensurePackage: #'Zinc-HTTP-Examples' withTags: #()!
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
testing
isComplete
^ username notNil & password notNil
^ username isNotNil & password isNotNil
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
printing
printContentsOn: stream
super printContentsOn: stream.
self bytes notNil ifTrue: [
self bytes isNotNil ifTrue: [
stream space; print: self bytes ]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
private
ensureChunkBufferOfSize: size
(chunk notNil and: [ size <= chunk size ]) ifTrue: [ ^ self ].
(chunk isNotNil and: [ size <= chunk size ]) ifTrue: [ ^ self ].
chunk := self collectionSpecies new: size
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cleanupConnection
or: [
self streaming not
and: [
(request notNil and: [ request wantsConnectionClose ])
or: [ response notNil and: [ response wantsConnectionClose ] ] ] ])
(request isNotNil and: [ request wantsConnectionClose ])
or: [ response isNotNil and: [ response wantsConnectionClose ] ] ] ])
ifTrue: [
self close ]
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ testing
isConnected
"Return true if I hold an open HTTP connection."

^ connection notNil and: [ connection isConnected ]
^ connection isNotNil and: [ connection isConnected ]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ newConnectionTo: url
| initialMilliseconds |
self signalHTTPProgress: 'Connecting to ', url authority.
initialMilliseconds := Time millisecondClockValue.
(connection notNil and: [ connection isConnected ])
(connection isNotNil and: [ connection isConnected ])
ifTrue: [ connection close ].
connection := ZnNetworkingUtils socketStreamToUrl: url.
url hasSecureScheme
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ resetEntity
This is sometimes necessary after a POST or PUT. This method will be called automatically
by #method: for certain requests."

(request notNil and: [ request hasEntity ])
(request isNotNil and: [ request hasEntity ])
ifTrue: [ request resetEntity: nil ]
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
testing
isComplete
^ super isComplete & nonce notNil
^ super isComplete & nonce isNotNil
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
testing
hasContentLength
^ contentLength notNil
^ contentLength isNotNil
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
testing
hasContentType
^ contentType notNil
^ contentType isNotNil
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
testing
allowsReadingUpToEnd
^ allowReadingUpToEnd notNil and: [ allowReadingUpToEnd ]
^ allowReadingUpToEnd isNotNil and: [ allowReadingUpToEnd ]
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
testing
isBinary
^ binary notNil and: [ binary ]
^ binary isNotNil and: [ binary ]
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
testing
isStreaming
^ streaming notNil and: [ streaming ]
^ streaming isNotNil and: [ streaming ]
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
testing
hasEntity
^ self entity notNil
^ self entity isNotNil
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
testing
hasHeaders
^ headers notNil and: [ self headers isEmpty not ]

^ headers isNotNil and: [ self headers isNotEmpty ]
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ hasSession
"Return if there currently is a server session.
This only returns a value during #handleRequest:"

^ ZnCurrentServerSession value notNil
^ ZnCurrentServerSession value isNotNil
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ resetEntity: object
even if I am already describing an entity using my content type and length.
See also: #clearEntity"

(entity ~= object and: [ entity notNil ])
(entity ~= object and: [ entity isNotNil ])
ifTrue: [ entity close ].
entity := object.
self headers acceptEntityDescription: object
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
testing
hasEntity
^ self entity notNil
^ self entity isNotNil
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
testing
hasHeaders
^ headers notNil and: [ self headers isEmpty not ]
^ headers isNotNil and: [ self headers isNotEmpty ]
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ at: key put: value
at: key
with: value
retrySelector: #at:put:) signal ].
(parent notNil and: [ parent includesKey: key ])
(parent isNotNil and: [ parent includesKey: key ])
ifFalse: [ KeyNotFound signalFor: key in: self ].
options ifNil: [ options := Dictionary new ].
^ options at: key put: value
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
testing
includesKey: key
^ (options notNil and: [ options includesKey: key ])
or: [ parent notNil and: [ parent includesKey: key ] ]
^ (options isNotNil and: [ options includesKey: key ])
or: [ parent isNotNil and: [ parent includesKey: key ] ]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
printing
printMethodAndUriOn: stream
(self method notNil and: [ self uri notNil ])
(self method isNotNil and: [ self uri isNotNil ])
ifFalse: [ ^ self ].
stream
nextPutAll: self method;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
printing
printOn: stream
super printOn: stream.
(self method notNil and: [ self uri notNil ])
(self method isNotNil and: [ self uri isNotNil ])
ifFalse: [ ^ self ].
stream nextPut: $(.
self printMethodAndUriOn: stream.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ testing
isListening
"Return true when I have a valid server socket listening at the correct port"

^ self serverSocket notNil
^ self serverSocket isNotNil
and: [ self serverSocket isValid and: [ self serverSocket localPort = self port ] ]
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ testing
isRunning
"Return true when I am running"

^ self process notNil and: [ self serverSocket notNil ]
^ self process isNotNil and: [ self serverSocket isNotNil ]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
encoder: anEncoding
(encoder notNil and: [ anEncoding ~= encoder ]) ifTrue: [ self invalidateContentLength ].
(encoder isNotNil and: [ anEncoding ~= encoder ]) ifTrue: [ self invalidateContentLength ].
encoder := anEncoding
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
private
hasEncoder
^ encoder notNil
^ encoder isNotNil
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
printing
printContentsOn: stream

super printContentsOn: stream.
self string notNil ifTrue: [
stream space; nextPutAll: self string ]
self string ifNotNil: [
stream
space;
nextPutAll: self string ]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
string: aString
(string notNil and: [ aString ~= string ]) ifTrue: [ self invalidateContentLength ].
(string isNotNil and: [ aString ~= string ]) ifTrue: [ self invalidateContentLength ].
string := aString
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ readUpToEnd: inputStream limit: limit
[ inputStream atEnd ] whileFalse: [ | readCount |
readCount := inputStream readInto: buffer startingAt: 1 count: bufferSize.
totalRead := totalRead + readCount.
(limit notNil and: [ totalRead > limit ])
(limit isNotNil and: [ totalRead > limit ])
ifTrue: [ ZnEntityTooLarge signal ].
outputStream ifNil: [
inputStream atEnd
Expand Down
9 changes: 1 addition & 8 deletions repository/Zinc-HTTP.package/monticello.meta/categories.st
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
SystemOrganization addCategory: #'Zinc-HTTP'!
SystemOrganization addCategory: #'Zinc-HTTP-Client-Server'!
SystemOrganization addCategory: #'Zinc-HTTP-Core'!
SystemOrganization addCategory: #'Zinc-HTTP-Exceptions'!
SystemOrganization addCategory: #'Zinc-HTTP-Logging'!
SystemOrganization addCategory: #'Zinc-HTTP-Streaming'!
SystemOrganization addCategory: #'Zinc-HTTP-Support'!
SystemOrganization addCategory: #'Zinc-HTTP-Variables'!
self packageOrganizer ensurePackage: #'Zinc-HTTP' withTags: #(#'Client-Server' #Core #Exceptions #Logging #Streaming #Support #Variables)!
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
testing
hasParameters
^ parameters notNil and: [ parameters isEmpty not ]
^ parameters isNotNil and: [ parameters isNotEmpty ]
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
testing
isCharSetUTF8
^ self charSet notNil and: [ self charSet sameAs: 'utf-8' ]
^ self charSet isNotNil and: [ self charSet sameAs: 'utf-8' ]
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ private
checkLimitForKey: aKey
"Signal an exception when the limit, if present, is exceeded."

(self limit notNil and: [ self size >= self limit and: [ (self includesKey: aKey) not ]])
(self limit isNotNil and: [ self size >= self limit and: [ (self includesKey: aKey) not ]])
ifTrue: [ (ZnTooManyDictionaryEntries limit: self limit) signal ]
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
testing
hasFragment
^ fragment notNil
^ fragment isNotNil
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
testing
hasHost
^ host notNil
^ host isNotNil
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
testing
hasPassword
^ password notNil
^ password isNotNil
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
testing
hasPath
^ segments notNil and: [ segments isEmpty not ]
^ segments isNotNil and: [ segments isNotEmpty ]
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
testing
hasPort
^ port notNil
^ port isNotNil
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
testing
hasQuery
^ query notNil and: [ query isEmpty not ]
^ query isNotNil and: [ query isEmpty not ]
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
testing
hasScheme
^ scheme notNil
^ scheme isNotNil
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
testing
hasUsername
^ username notNil
^ username isNotNil
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SystemOrganization addCategory: #'Zinc-Resource-Meta-Core'!
self packageOrganizer ensurePackage: #'Zinc-Resource-Meta-Core' withTags: #()!
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ testRedirectWithCookies
yourself ]
ifFalse: [
cookie := request cookies detect: [ :each | each name = 'session' ] ifNone: [ nil ].
(request uri firstPathSegment = 'two' and: [ cookie notNil and: [ cookie value = '123456' ] ])
(request uri firstPathSegment = 'two' and: [ cookie isNotNil and: [ cookie value = '123456' ] ])
ifTrue: [ ZnResponse ok: (ZnEntity text: 'OK!') ]
ifFalse: [ ZnResponse badRequest: request ] ] ].
(client := ZnClient new)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ testMultiPartFormDataWriteRead
addPart: (ZnMimePart fieldName: 'info' value: 'my-info');
addPart: (ZnMimePart fieldName: 'file' fileName: 'foo.txt' entity: (ZnEntity text: 'Zinc HTTP Components'));
yourself.
self assert: input contentLength notNil.
self assert: input contentLength isNotNil.
self assert: input contentLength > 0.
self assert: (input contentType matches: ZnMimeType multiPartFormData).
bytes := ByteArray streamContents: [ :stream | input writeOn: stream ].
Expand Down
Loading

0 comments on commit 97afe55

Please sign in to comment.