2
2
# (c) Software Lab. Alexander Burger
4
4
# *Home *Gate *Host *Port *Port1 *Port% *Http1 *Chunked
5
# *Sock *Agent *ContLen *MPartLim *MPartEnd "*HtSet"
5
# *Sock *Agent *ContL *ContLen *MPartLim *MPartEnd "*HtSet"
6
6
# *Post *Url *Timeout *SesAdr *SesId *ConId
7
7
# *Referer *Cookies "*Cookies"
119
121
(and *Tmp (pre? *Tmp *Url))
120
122
(find pre? (cdr *Allow) (circ *Url)) ) ) ) )
123
125
(unless (= X "favicon.ico")
124
(msg X S " [" *Adr "] not allowed") ) )
126
(msg X " [" *Adr "] not allowed") ) )
126
128
# Application startup
160
162
(*MPartLim (_htMultipart))
162
((if *ContLen (ht:Read @) (line))
164
((cond (*ContL (line)) (*ContLen (ht:Read @)))
163
165
(for L (split @ '&)
164
166
(when (setq L (split L "="))
165
167
(let? S (_htSet (car L) (ht:Pack (cadr L)))
226
228
(T (httpEcho *Url "application/octet-stream" 1 T)) ) ) ) ) )
227
229
(and S (=0 *Http1) (task (close S))) ) )
233
((index ":" H) (head (dec @) H))
238
(setq *Http1 (format (car @H)) *Chunked (gt0 *Http1) Pil)
233
(setq *Http1 (format (car @H)) *Chunked (gt0 *Http1))
239
234
(if (index "~" @U)
241
236
*ConId (head @ @U)
264
259
*MPartLim (append '(- -) @X)
265
260
*MPartEnd (append *MPartLim '(- -)) ) )
266
261
((match '(~(chop "X-Pil: ") @X "=" . @Y) L)
267
(fifo 'Pil (list 'setq (intern (pack @X)) (htArg @Y))) ) ) )
269
(eval (fifo 'Pil)) ) ) )
262
(_htSet @X (ht:Pack @Y)) ) ) )
264
(and (member ":" *Host) (con (prior @ *Host))) ) ) )
271
266
# rfc1867 multipart/form-data
272
267
(de _htMultipart ()
301
296
(out "/dev/null" (echo (pack "^M^J" *MPartLim))) )
302
297
(setq L (if (= "-" (car (line))) *MPartEnd *MPartLim)) ) ) ) ) )
304
(de _htSet ("Var" Val)
305
(let (@N NIL @Z NIL @V)
309
(ifn (match '(@V ":" @N ":" @Z) "Var")
311
(setq @N (format @N))
316
((= @Z '("." "x")) (cons (format Val)))
317
((= @Z '("." "y")) (cons NIL (format Val)))
318
(T (msg @Z " bad suffix") (throw 'http)) ) ) )
300
(let "Var" (intern (ht:Pack (car (setq L (split L ":")))))
320
302
((and *Allow (not (idx *Allow "Var")))
321
(notAllowed "Var" ':)
325
((= `(char '*) (char "Var")) (put "Var" 'http Val))
326
((and @Z (val "Var")) (set "Var" Val))
327
((car Val) (con (val "Var") (cdr Val)))
328
(NIL (set (val "Var") (car Val))) ) )
329
((not (memq "Var" "*HtSet"))
330
(push '"*HtSet" "Var")
331
(set "Var" (cons (cons @N Val)))
333
((assoc @N (val "Var"))
336
((nand @Z (cdr X)) (con X Val))
337
((car Val) (set (cdr X) @))
338
(T (con (cdr X) (cdr Val))) ) ) )
306
(let? N (format (car (setq L (split @ "."))))
308
("x" (setq Val (cons (format Val))))
309
("y" (setq Val (cons NIL (format Val)))) )
311
((memq "Var" "*HtSet")
312
(push '"*HtSet" "Var")
313
(set "Var" (cons (cons N Val)))
315
((assoc N (val "Var"))
316
(queue "Var" (cons N Val))
321
((nand (cadr L) (cdr X)) (con X Val))
322
((car Val) (set (cdr X) @))
323
(T (con (cdr X) (cdr Val))) ) ) ) ) ) )
340
(queue "Var" (cons @N Val))
327
(put "Var" 'http Val) ) ) ) ) )