Paste: fcgi error

Author: brennanc
Mode: factor
Date: Wed, 5 May 2010 18:48:51
Plain Text |
USING: accessors alien.enums alien.syntax combinators combinators.smart io                                                                                                                                                                                                                                                                                                                    
io.directories io.encodings.binary io.files io.files.info.unix                                                                                                                                                                                                                                                                                                                                
io.sockets kernel namespaces pack prettyprint ;
IN: fastcgi

SYMBOL: fcgi-server

CONSTANT: socket-path "/chroot/web/var/run/factor.sock"

TUPLE: fcgi-header version type request-id content-length                                                                                                                                                                                                                                                                                                                                     
    padding-length reserved ;

ENUM: fcgi-header-types                                                                                                                                                                                                                                                                                                                                                                       
    { FCGI_BEGIN_REQUEST 1 }                                                                                                                                                                                                                                                                                                                                                                  
    FCGI_ABORT_REQUEST                                                                                                                                                                                                                                                                                                                                                                        
    FCGI_END_REQUEST                                                                                                                                                                                                                                                                                                                                                                          
    FCGI_PARAMS                                                                                                                                                                                                                                                                                                                                                                               
    FCGI_STDIN                                                                                                                                                                                                                                                                                                                                                                                
    FCGI_STDOUT                                                                                                                                                                                                                                                                                                                                                                               
    FCGI_STDERR                                                                                                                                                                                                                                                                                                                                                                               
    FCGI_DATA                                                                                                                                                                                                                                                                                                                                                                                 
    FCGI_GET_VALUES                                                                                                                                                                                                                                                                                                                                                                           
    FCGI_GET_VALUES_RESULT                                                                                                                                                                                                                                                                                                                                                                    
    FCGI_UNKNOWN_TYPE                                                                                                                                                                                                                                                                                                                                                                         
    { FCGI_MAXTYPE 11 } ;

: allow-permissions ( -- )
    socket-path OCT: 777 set-file-permissions ;

: delete-if-exists ( file -- )
    dup exists? [ delete-file ] [ drop ] if ;

: make-socket ( -- )
    socket-path [ delete-if-exists ] keep
    <local> binary <server>
    fcgi-server set
    allow-permissions ;

: get-header ( stream -- header )
    [ "CCSSCC" read-packed-be ] with-input-stream*
    [ fcgi-header boa ] input<sequence ;

: process-begin-request ( header -- )
    "begin-request" print . ;

: dispatch-by-header ( header -- )
    dup type>>
    {
      { FCGI_BEGIN_REQUEST enum>number [ process-begin-request ] }
     } case ;

: get-request ( -- x )
    fcgi-server get accept drop
    get-header ;

New Annotation

Summary:
Author:
Mode:
Body: