WebGate

Check-in [22158254d8]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Clean up tcp listener in webgate-main using dynamic wind
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:22158254d84b0d464018856fc70487fe0c3fa1a6
User & Date: murphy 2013-05-31 23:14:11
Context
2013-06-02
15:19
The parameters table should not be part of the serialization context check-in: 853b10e568 user: murphy tags: trunk
2013-05-31
23:14
Clean up tcp listener in webgate-main using dynamic wind check-in: 22158254d8 user: murphy tags: trunk
12:37
More consistent signature for make-redirect-response check-in: bc50958c55 user: murphy tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to webgate.scm.

64
65
66
67
68
69
70
71

72
73
74
75
76
77
78
...
104
105
106
107
108
109
110










111
112
113
114
115
116
117
118
119
120

121
122
123
124
125
126
127
128
129
130
131
132



133

134
135
136
137
138
139
140
141
142
   resource-context current-resource-context resource-context?
   resource-context-getenv resource-context-method resource-context-path
   response make-response response?
   collect-response make-html-response make-error-response
   make-redirect-response
   response-status response-status-message
   write-response
   resource-handler define-resource resource-uri

   handle-query-parameters
   handle-request)
  (import
   scheme chicken
   srfi-1 srfi-4 srfi-13 srfi-18 srfi-69 srfi-99
   data-structures ports extras lolevel irregex
   protobuf-generic suspension webgate-utils)
................................................................................
   scheme chicken
   srfi-13 srfi-18 srfi-69
   data-structures irregex webgate-utils tcp)
  (include
   "webgate-scgi.scm"))

(module webgate










  (message make-message message?
   message-type message-headers message-body message-text
   parameter-list-ref parameter-ref
   resource-context current-resource-context resource-context?
   resource-context-getenv resource-context-method resource-context-path
   response make-response response?
   collect-response make-html-response make-error-response
   make-redirect-response
   response-status response-status-message
   resource-handler define-resource resource-uri

   send/suspend
   webgate-main)
  (import
   scheme chicken
   srfi-13 webgate-core webgate-suspend webgate-cgi webgate-scgi tcp)

(define (webgate-main #!optional (arguments (command-line-arguments)))
  (apply
   (lambda (#!key port (backlog 4) (host "localhost") (suspension-key #f))
     (cond
      (suspension-key => current-suspension-key))
     (if port



	 (scgi-main-loop handle-request (tcp-listen port backlog host))

	 (cgi-main-loop handle-request)))
   (map
    (lambda (arg)
      (if (string-prefix? "-" arg)
	  (string->keyword (substring/shared arg 1))
	  (or (string->number arg) arg)))
    arguments)))

)







|
>







 







>
>
>
>
>
>
>
>
>
>
|
|
|
|
|
|
|
|
|
|
>
|
<
<
<
<







>
>
>
|
>









64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
...
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133




134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
   resource-context current-resource-context resource-context?
   resource-context-getenv resource-context-method resource-context-path
   response make-response response?
   collect-response make-html-response make-error-response
   make-redirect-response
   response-status response-status-message
   write-response
   resource-handler resource-uri
   (define-resource resource-handler extend-procedure procedure-data)
   handle-query-parameters
   handle-request)
  (import
   scheme chicken
   srfi-1 srfi-4 srfi-13 srfi-18 srfi-69 srfi-99
   data-structures ports extras lolevel irregex
   protobuf-generic suspension webgate-utils)
................................................................................
   scheme chicken
   srfi-13 srfi-18 srfi-69
   data-structures irregex webgate-utils tcp)
  (include
   "webgate-scgi.scm"))

(module webgate
  (webgate-main)
  (import
   scheme chicken
   srfi-13 webgate-cgi webgate-scgi tcp
   (only webgate-core
	 handle-request)
   (only webgate-suspend
	 current-suspension-key))
  (reexport
   (only webgate-core
	 message make-message message?
	 message-type message-headers message-body message-text
	 parameter-list-ref parameter-ref
	 resource-context current-resource-context resource-context?
	 resource-context-getenv resource-context-method resource-context-path
	 response make-response response?
	 collect-response make-html-response make-error-response
	 make-redirect-response
	 response-status response-status-message
	 define-resource resource-uri)
   (only webgate-suspend 
	 send/suspend))





(define (webgate-main #!optional (arguments (command-line-arguments)))
  (apply
   (lambda (#!key port (backlog 4) (host "localhost") (suspension-key #f))
     (cond
      (suspension-key => current-suspension-key))
     (if port
	 (let ((ear (tcp-listen port backlog host)))
	   (dynamic-wind
	       void
	       (cut scgi-main-loop handle-request ear)
	       (cut tcp-close ear)))
	 (cgi-main-loop handle-request)))
   (map
    (lambda (arg)
      (if (string-prefix? "-" arg)
	  (string->keyword (substring/shared arg 1))
	  (or (string->number arg) arg)))
    arguments)))

)