diff -u --recursive serialise.ss serialise.ss --- serialise.ss 2006-11-08 16:00:28.000000000 -0500 +++ serialise.ss 2006-11-12 17:22:08.000000000 -0500 @@ -119,7 +119,7 @@ `(value (int ,(number->string val))) (raise-exn:xmlrpc (format "The Scheme number ~s is out of range for an XML-RPC integer" val)))] - [(string? val) `(value (string ,((encode-string) val)))] + [(string? val) `(value (string ,val))] ;; 20060711 MCJ ;; We could encode symbols as strings. However, this breaks ;; the semantics of Scheme. Should we force users to send @@ -188,7 +188,7 @@ [(double ,v) (string->number v)] ;; Strings [(string) ""] - [(string ,v) ((decode-string) v)] + [(string ,v) v] ;; Booleans [(boolean ,v) (string=? v "1")] diff -u --recursive server-core.ss server-core.ss --- server-core.ss 2006-11-08 16:00:28.000000000 -0500 +++ server-core.ss 2006-11-12 17:19:15.000000000 -0500 @@ -1,7 +1,9 @@ (module server-core mzscheme - (require (lib "servlet-helpers.ss" "web-server") + (require (lib "servlet.ss" "web-server") (file "serialise.ss") - (file "protocol.ss")) + (file "protocol.ss") + (lib "response.ss" "web-server") + (lib "xml.ss" "xml")) (provide (all-defined)) ;; XML-RPC Environment @@ -35,14 +37,11 @@ [arg-length (length args)]) (cond [(= arity arg-length) - (let ([serialised-result - (serialise (apply fun args))]) - `(methodResponse - (params - (param - ;; Is there an inconsistent wrapping of 'value' - ;; around this? - ,serialised-result))))] + (let* ([result (apply fun args)] + [serialised-result (serialise result)]) + (printf "result: ~s~n" result) + (printf "serialized-result: ~s~n" serialised-result) + (make-response serialised-result))] [else (make-handler-fault (format "You invoked '~a' with ~a parameters; '~a' expects ~a." @@ -51,6 +50,20 @@ )]) )) + (define (make-response serialised-result) + (let* ([response `(methodResponse + (params + (param + ;; Is there an inconsistent wrapping of 'value' + ;; around this? + ,serialised-result)))] + [output (string->bytes/utf-8 (xexpr->string response))]) + (make-response/full + 200 "Okay" (current-seconds) + #"text/xml" '() + (list output)))) + + ;; make-handler-fault : string num -> methodResponse ;; Makes the XML-RPC 'fault' method response. ;; The error codes thrown by this library should be chosen @@ -72,17 +85,7 @@ ;; struct:request looks like: ;; method uri headers/raw bindings/raw ;; host-ip host-port client-ip - (let ([raw-bindings (request-bindings/raw request)]) - ;; This string-append is because the bindings come in - ;; mangled for XML-RPC content; it seems like the webserver - ;; tears it up in a syntactically bogus location (w.r.t. the - ;; structure of the XML document.) - (apply string-append - (map (lambda (b) - (format "~a~a" - (binding-id b) - (binding:form-value b))) - raw-bindings)))) + (bytes->string/utf-8 (request-post-data/raw request))) ;; handle-xmlrpc-servlet-request* : request -> methodResponse ;; Returns the value of the computation requested by the user,