Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use SocketError next to PrimitiveFailed #16

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ setupTLSTo: url
connection sslSession certificateName: self certificate.

[ connection sslSession serverName: url host ]
on: PrimitiveFailed
on: (ZnUtils exceptionSet: #( #SocketError #PrimitiveFailed ))
do: [ :error | "log it?" ].

connection connect

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ readRequestBadExceptionSet
"Return the set of exceptions which, when they occur while reading a request,
are interpreted as equivalent to a request parse error or bad request."

^ self
^ ZnUtils
exceptionSet:
#(#ZnParseError #ZnCharacterEncodingError #ZnUnknownScheme #ZnPortNotANumber #ZnTooManyDictionaryEntries #ZnEntityTooLarge)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ readRequestTerminationExceptionSet
"Return the set of exceptions which, when they occur while reading a request,
are interpreted as equivalent to a timeout or connection close."

^ self
^ ZnUtils
exceptionSet:
#(#ConnectionClosed #ConnectionTimedOut #PrimitiveFailed)
#(#ConnectionClosed #ConnectionTimedOut #SocketError #PrimitiveFailed)
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ writeResponseTerminationExceptionSet
"Return the set of exceptions which, when they occur while writing a response,
are interpreted as equivalent to a timeout or connection close."

^ self exceptionSet: #(#ConnectionClosed #ConnectionTimedOut #PrimitiveFailed)
^ ZnUtils
exceptionSet:
#(#ConnectionClosed #ConnectionTimedOut #SocketError #PrimitiveFailed)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
converting
exceptionSet: classNames
^ classNames inject: ExceptionSet new into: [ :set :each |
(Smalltalk globals includesKey: each)
ifTrue: [
set
add: (Smalltalk at: each);
yourself ]
ifFalse: [ set ] ]
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,17 +1,21 @@
testing
testLogging

| client logEventCollection count |
logEventCollection := OrderedCollection new.
ZnLogEvent announcer
when: ZnLogEvent do: [ :event | logEventCollection add: event ].
when: ZnLogEvent
do: [ :event | logEventCollection add: event ]
for: self.
(client := ZnClient new)
clientId: #C1;
beOneShot.
client get: self smallHtmlUrl.
client close.
count := ZnLogEvent announcer numberOfSubscriptions.
ZnLogEvent announcer
unsubscribe: self.
self assert: ZnLogEvent announcer numberOfSubscriptions equals: count -1.
ZnLogEvent announcer unsubscribe: self.
self
assert: ZnLogEvent announcer numberOfSubscriptions
equals: count - 1.
self deny: logEventCollection isEmpty.
self assert: logEventCollection anyOne clientId equals: #C1
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
tests
testLogging

| client logEventCollection count renderedLogEvents |
logEventCollection := OrderedCollection new.
ZnLogEvent announcer
when: ZnLogEvent do: [ :event | logEventCollection add: event ].
when: ZnLogEvent
do: [ :event | logEventCollection add: event ]
for: self.
self withServerDo: [ :server |
1 to: 3 do: [ :logLevel |
server serverId: ('S' , logLevel asString) ; logLevel: logLevel.
server
serverId: 'S' , logLevel asString;
logLevel: logLevel.
client := ZnClient new.
client clientId: ('C' , logLevel asString); logLevel: logLevel.
client
clientId: 'C' , logLevel asString;
logLevel: logLevel.
client get: (server localUrl addPathSegment: #small).
self assert: client isSuccess.
client get: (server localUrl addPathSegment: #error).
self deny: client isSuccess.
server delegate map: #redirect to: [ :request | ZnResponse redirect: #welcome ].
server delegate
map: #redirect
to: [ :request | ZnResponse redirect: #welcome ].
client get: (server localUrl addPathSegment: #redirect).
self assert: client isSuccess.
self assert: client isSuccess.
client close ] ].
count := ZnLogEvent announcer numberOfSubscriptions.
ZnLogEvent announcer
unsubscribe: self.
self assert: ZnLogEvent announcer numberOfSubscriptions equals: count -1.
ZnLogEvent announcer unsubscribe: self.
self
assert: ZnLogEvent announcer numberOfSubscriptions
equals: count - 1.
self deny: logEventCollection isEmpty.
renderedLogEvents := String streamContents: [ :out |
logEventCollection do: [ :event | out print: event; cr ] ].
renderedLogEvents := String streamContents: [ :out |
logEventCollection do: [ :event |
out
print: event;
cr ] ].
self deny: renderedLogEvents isEmpty
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SystemOrganization addCategory: #'Zinc-Tests'!
self packageOrganizer ensurePackage: #'Zinc-Tests' withTags: #()!
Loading