Changeset 15250 in project


Ignore:
Timestamp:
07/25/09 16:21:46 (10 years ago)
Author:
sjamaan
Message:

Implement a simple xml-rpc procedure

Location:
release/4/xml-rpc/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/xml-rpc/trunk/tests/run.scm

    r15249 r15250  
    430430(define handler (make-xml-rpc-request-handler `((scheme.List . ,list))))
    431431
    432 (test-group "Request handling"
     432(test-group "request handling"
    433433  (call-with-input-string "doesn't matter"
    434434    (lambda (in)
  • release/4/xml-rpc/trunk/xml-rpc-server.scm

    r15249 r15250  
    4141(module xml-rpc-server
    4242  (call-xml-rpc-proc xml-rpc-call->xml-rpc-response
    43    make-xml-rpc-request-handler)
     43   make-xml-rpc-request-handler start-simple-xml-rpc-server)
    4444
    4545(import chicken scheme)
    46 (use srfi-13 extras data-structures xml-rpc-lolevel sxpath-lolevel ssax intarweb)
     46(use srfi-13 srfi-18 extras data-structures tcp
     47     xml-rpc-lolevel sxpath-lolevel ssax intarweb)
    4748
    4849(define (call-xml-rpc-proc call-sxml procedures)
     
    136137          resp))))
    137138
     139(define (start-simple-xml-rpc-server procedures #!optional (port 8080))
     140  (let ((listener (tcp-listen port))
     141        (handler (make-xml-rpc-request-handler procedures)))
     142    (let accept-next-connection ()
     143      (receive (in out)
     144        (tcp-accept listener)
     145        (thread-start!
     146         (lambda ()
     147           (handle-exceptions e
     148             (void)
     149             (let ((req (read-request in))
     150                   (resp (make-response port: out)))
     151               (handler req resp)))))
     152        (accept-next-connection)))))
     153
    138154)
Note: See TracChangeset for help on using the changeset viewer.