Swazoo.HTTPConnection>>produceResponseFor: uses for:onAnyExceptionDo: catching Notifications

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Swazoo.HTTPConnection>>produceResponseFor: uses for:onAnyExceptionDo: catching Notifications

I'm finding the exception handling in Swazoo.HTTPConnection>>produceResponseFor: to be a bit intrusive.  Maybe I'm the only one?  My Swazoo response handlers are basically forced to include something like:

[self performOperation] on: Notification do: [:ex | ex resume]

to avoid having Notifications that are normally happily ignored from trigger Swazoo to produce #internalServerError.  The most common example is EndOfStreamNotification which is often silently triggered and ignored by code which expects to get a nil back from an exhausted stream.  My suggestion is to change to for:onAnyErrorDo: as listed below.  Anyone else in favor of this change?

produceResponseFor: aSwazooTask
        aSwazooTask request isNil ifTrue: [^nil].
        SpExceptionContext for:
                [aSwazooTask response: (self server answerTo: aSwazooTask request).
                aSwazooTask request ensureFullRead. "in case if defered parsing not done in HTTPost"
                aSwazooTask request wantsConnectionClose
                        ifTrue: [aSwazooTask response informConnectionClose]
                        ifFalse: [aSwazooTask request isKeepAlive
                                ifTrue: [aSwazooTask response informConnectionKeepAlive] ].
                aSwazooTask response isStreamed
                        ifFalse: "streamed ones did that by themselves"
                                [self nextPutResponse: aSwazooTask response toRequest: aSwazooTask request]
                        ifTrue: [aSwazooTask response waitClose]. "to be sure all is sent"
                aSwazooTask request isGet ifFalse: [self close]  ] "to avoid strange 200 bad requests after two consecutive POSTs, but it is really a hack and original reason must be found!" "jan11: do we still need this?"
                [:ex |
                self nextPutError: HTTPResponse internalServerError.
                ex defaultAction. "usually raise an UHE window"
                self close]
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
Swazoo-devel mailing list
[hidden email]