Megatest

Check-in [dae2c48a5c]
Login
Overview
Comment:example client and server for http
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | http-transport
Files: files | file ages | folders
SHA1: dae2c48a5cc403f6ee4dc7342f3bff52c3e5dcbe
User & Date: matt on 2013-01-14 20:21:07
Other Links: branch diff | manifest | tags
Context
2013-01-14
22:17
first pass implemenation using http check-in: 0d7a6d510a user: matt tags: http-transport
20:21
example client and server for http check-in: dae2c48a5c user: matt tags: http-transport
13:41
Start of trial use of http instead of zmq check-in: ab15a4abf5 user: mrwellan tags: http-transport
Changes

Added testhttp/example-client.scm version [83732ef8d7].




1
2
3
+
+
+
(use http-client)

(print (with-input-from-request "http://localhost:8082/?foo=1" #f read-string))

Added testhttp/example-server.scm version [d5822303ef].



























1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
(use spiffy awful)

(tcp-buffer-size 2048)
(enable-sxml #t)

(define (hello-world)
  (define-page (main-page-path)
    (lambda ()
      (with-request-variables (foo)
        (conc foo " Hello, world! Goodbye Dolly")))))

(define (start-server #!key (portnum 8080))
  (handle-exceptions
   exn
   (begin
     (print-error-message exn)
     (if (< portnum 9000)
	 (begin 
	   (print "WARNING: failed to start on portnum: " portnum ", trying next port")
	   (sleep 1)
	   (start-server portnum: (+ portnum 1)))
	 (print "ERROR: Tried and tried but could not start the server")))
   (print "INFO: Trying to start server on portnum: " portnum)
   (awful-start hello-world port: portnum)))

(start-server)

Modified testhttp/mockupserver.scm from [d64eb07b64] to [aa3c5bcdcf].

1
2
3
4
5
6
7
8
9
10
11
12

13
14
15
16
17
18
19
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20












+







;; pub/sub with envelope address
;; Note that if you don't insert a sleep, the server will crash with SIGPIPE as soon
;; as a client disconnects.  Also a remaining client may receive tons of
;; messages afterward.

(use srfi-18 sqlite3 spiffy)

(define cname "server")
(define total-db-accesses 0)
(define start-time (current-seconds))

;; setup the server here
(tcp-buffer-size 2048)
(server-port 5563)

(define (open-db)
  (let* ((dbpath    "mockup.db")
	 (dbexists  (file-exists? dbpath))
	 (db        (open-database dbpath)) ;; (never-give-up-open-db dbpath))
	 (handler   (make-busy-timeout 10)))