Fix http server
							parent
							
								
									e7ec34050b
								
							
						
					
					
						commit
						2d381ed84e
					
				| 
						 | 
					@ -25,7 +25,7 @@ M: template-lexer skip-word
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            { [ 2dup nth CHAR: " = ] [ drop 1+ ] }
 | 
					            { [ 2dup nth CHAR: " = ] [ drop 1+ ] }
 | 
				
			||||||
            { [ 2dup swap tail-slice "%>" head? ] [ drop 2 + ] }
 | 
					            { [ 2dup swap tail-slice "%>" head? ] [ drop 2 + ] }
 | 
				
			||||||
            { [ t ] [ [ blank? ] skip ] }
 | 
					            { [ t ] [ f skip ] }
 | 
				
			||||||
        } cond
 | 
					        } cond
 | 
				
			||||||
    ] change-column ;
 | 
					    ] change-column ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -29,7 +29,7 @@ SYMBOL: log-stream
 | 
				
			||||||
 | 
					
 | 
				
			||||||
: with-log-file ( file quot -- )
 | 
					: with-log-file ( file quot -- )
 | 
				
			||||||
    >r <file-appender> r>
 | 
					    >r <file-appender> r>
 | 
				
			||||||
    [ with-log-stream ] with-disposal ; inline
 | 
					    [ with-log-stream ] curry with-disposal ; inline
 | 
				
			||||||
 | 
					
 | 
				
			||||||
: with-log-stdio ( quot -- )
 | 
					: with-log-stdio ( quot -- )
 | 
				
			||||||
    stdio get swap with-log-stream ;
 | 
					    stdio get swap with-log-stream ;
 | 
				
			||||||
| 
						 | 
					@ -47,11 +47,11 @@ SYMBOL: log-stream
 | 
				
			||||||
    dup log-client
 | 
					    dup log-client
 | 
				
			||||||
    [ swap with-stream ] 2curry concurrency:spawn drop ; inline
 | 
					    [ swap with-stream ] 2curry concurrency:spawn drop ; inline
 | 
				
			||||||
 | 
					
 | 
				
			||||||
: accept-loop ( server quot -- server quot )
 | 
					: accept-loop ( server quot -- )
 | 
				
			||||||
    [ swap accept with-client ] 2keep accept-loop ; inline
 | 
					    [ swap accept with-client ] 2keep accept-loop ; inline
 | 
				
			||||||
 | 
					
 | 
				
			||||||
: server-loop ( server quot -- )
 | 
					: server-loop ( server quot -- )
 | 
				
			||||||
    [ accept-loop ] compose with-disposal ; inline
 | 
					    [ accept-loop ] curry with-disposal ; inline
 | 
				
			||||||
 | 
					
 | 
				
			||||||
: spawn-server ( addrspec quot -- )
 | 
					: spawn-server ( addrspec quot -- )
 | 
				
			||||||
    "Waiting for connections on " pick unparse append
 | 
					    "Waiting for connections on " pick unparse append
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,8 +1,8 @@
 | 
				
			||||||
! Copyright (C) 2007 Slava Pestov.
 | 
					! Copyright (C) 2007, 2008 Slava Pestov.
 | 
				
			||||||
! See http://factorcode.org/license.txt for BSD license.
 | 
					! See http://factorcode.org/license.txt for BSD license.
 | 
				
			||||||
USING: namespaces kernel assocs io.files combinators
 | 
					USING: namespaces kernel assocs io.files combinators
 | 
				
			||||||
arrays io.launcher io http.server.responders webapps.file
 | 
					arrays io.launcher io http.server.responders webapps.file
 | 
				
			||||||
sequences strings math.parser ;
 | 
					sequences strings math.parser unicode.case ;
 | 
				
			||||||
IN: webapps.cgi
 | 
					IN: webapps.cgi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SYMBOL: cgi-root
 | 
					SYMBOL: cgi-root
 | 
				
			||||||
| 
						 | 
					@ -31,7 +31,7 @@ SYMBOL: cgi-root
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        "method" get >upper "REQUEST_METHOD" set
 | 
					        "method" get >upper "REQUEST_METHOD" set
 | 
				
			||||||
        "raw-query" get "QUERY_STRING" set
 | 
					        "raw-query" get "QUERY_STRING" set
 | 
				
			||||||
	"Cookie" header-param "HTTP_COOKIE" set 
 | 
					        "Cookie" header-param "HTTP_COOKIE" set 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        "User-Agent" header-param "HTTP_USER_AGENT" set
 | 
					        "User-Agent" header-param "HTTP_USER_AGENT" set
 | 
				
			||||||
        "Accept" header-param "HTTP_ACCEPT" set
 | 
					        "Accept" header-param "HTTP_ACCEPT" set
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue