refactor: changes spaces and instructions
use if, remove useless begin, 1 tab = 4 spaces
This commit is contained in:
parent
48c95a8370
commit
d8e1e49e58
1 changed files with 14 additions and 17 deletions
31
server.scm
31
server.scm
|
@ -18,30 +18,27 @@
|
||||||
(use-modules (ice-9 binary-ports) (ice-9 iconv) (rnrs bytevectors))
|
(use-modules (ice-9 binary-ports) (ice-9 iconv) (rnrs bytevectors))
|
||||||
|
|
||||||
(define chaussette (socket PF_INET SOCK_STREAM 0))
|
(define chaussette (socket PF_INET SOCK_STREAM 0))
|
||||||
(bind chaussette AF_INET INADDR_ANY 8082)
|
(bind chaussette AF_INET INADDR_ANY 8081)
|
||||||
(listen chaussette 1)
|
(listen chaussette 1)
|
||||||
(display "Chaussette en place")
|
(display "Chaussette en place")
|
||||||
(newline)
|
(newline)
|
||||||
(while #t
|
(while #t
|
||||||
(let (( rep (accept chaussette )))
|
(let (( rep (accept chaussette )))
|
||||||
(let ((out (car rep)) (in (cdr rep)))
|
(let ((out (car rep)) (in (cdr rep)))
|
||||||
(define text (make-bytevector 1024))
|
(define text (make-bytevector 1024))
|
||||||
(define pos #f)
|
(define pos #f)
|
||||||
(recvfrom! out text)
|
(recvfrom! out text)
|
||||||
|
|
||||||
(set! pos (string-contains (bytevector->string text "UTF-8")
|
(set! pos (string-contains (bytevector->string text "UTF-8")
|
||||||
(string #\return #\nl)))
|
(string #\return #\nl)))
|
||||||
|
|
||||||
;; si ya pas de \cr\nl, buffer trop grand ou mal formaté
|
;; si ya pas de \cr\nl, buffer trop grand ou mal formaté
|
||||||
(when (not pos) (begin
|
(if (not pos)
|
||||||
(display (string-append "59 Bad Request" (string #\return #\nl)) out))
|
(display (string-append "59 Bad Request" (string #\return #\nl)) out)
|
||||||
)
|
(display "all ok")
|
||||||
|
)
|
||||||
|
|
||||||
(unless (not pos) (begin
|
(shutdown out 2)
|
||||||
(display "all ok")
|
|
||||||
))
|
|
||||||
|
|
||||||
(shutdown out 2)
|
|
||||||
)))
|
)))
|
||||||
|
|
||||||
(close chaussette)
|
(close chaussette)
|
||||||
|
|
Loading…
Reference in a new issue