Christoph Thiede uploaded a new version of WebClient-Core to project The Inbox: http://source.squeak.org/inbox/WebClient-Core-ct.136.mcz
==================== Summary ====================
Name: WebClient-Core-ct.136 Author: ct Time: 23 January 2024, 10:25:18.473015 am UUID: ca5bdcb6-155a-8a43-8c3f-6c6f79b704c5 Ancestors: WebClient-Core-tpr.135
Allows web server to handle OPTIONS requests manually. For instance, this is required to handle CORS preflight stuff properly.
=============== Diff against WebClient-Core-tpr.135 ===============
Item was changed: ----- Method: WebServer>>dispatchRequest:url: (in category 'handling') ----- dispatchRequest: request url: dispatchUrl "Look up the handler for a given url and dispatch to it"
| entryUrl action | "Handle TRACE requests right away" request method = 'TRACE' ifTrue:[ ^request send200Response: request asString contentType: 'message/http'. ].
"Look up the entry point for the request" action := nil. entryUrl := dispatchUrl asLowercase. (entryUrl beginsWith: '/') ifFalse:[entryUrl := '/', entryUrl]. mutex critical:[ [entryUrl notEmpty and:[action == nil]] whileTrue: [ action := entryPoints at: entryUrl ifAbsent:[nil]. entryUrl := entryUrl copyUpToLast: $/. ]. action ifNil:[action := entryPoints at: '/' ifAbsent:[nil]]. ].
"Handle OPTIONS requests" + (request method = 'OPTIONS' + and: [((action at: 1) includes: request method) not] "action handles the request manually, (e.g.., to provide CORS headers)") ifTrue:[ - request method = 'OPTIONS' ifTrue:[ "HEAD, TRACE, and OPTIONS are always supported" request sendOptionsResponse: self builtinHttpMethods, (action ifNil:[self defaultHttpMethods] ifNotNil:[action first]) ].
"Handle 404 not found" action ifNil:[^request send404Response].
"Handle 405 method not allowed" (request method = 'HEAD' "builtin" or:[(action at: 1) includes: request method]) ifFalse:[ ^request send405Response: self builtinHttpMethods, action first. ].
^[self invokeAction: (action at: 2) request: request] on: Error do:[:ex| errorHandler ifNil:[self handleError: ex request: request] ifNotNil:[errorHandler value: ex value: request] ]. !
squeak-dev@lists.squeakfoundation.org