Changeset 1925

Show
Ignore:
Timestamp:
09/01/08 12:09:18 (3 months ago)
Author:
alo
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • cherokee/trunk/cherokee/handler_cgi_base.c

    r1924 r1925  
    533533 
    534534        /* SCRIPT_NAME: 
    535          * RFC 3875: "URI path identifying the CGI script". 
    536          * 
    537          * For a CGI, it is the request without the PATHINFO, if any 
    538          * 
    539          * For a SCGI and FCGI, it is the request minus the pathinfo, 
    540          * which is request until the second slash character beginning 
    541          * at webdir length. 
    542          *  
     535         * It is the request without the pathinfo if it exists 
    543536         */ 
    544537        cherokee_buffer_clean (&tmp); 
    545538 
    546539        if (! cgi_props->check_file) { 
    547                 /* SCGI or FastCGI 
    548                  */ 
    549                 cherokee_buffer_add (&tmp, 
    550                                     conn->request.buf, 
    551                                     conn->request.len - conn->pathinfo.len); 
    552  
     540                /* SCGI or FastCGI */ 
     541 
     542                if (conn->web_directory.len > 1) { 
     543                        cherokee_buffer_add_buffer (&tmp, &conn->web_directory); 
     544                } 
     545                 
    553546                cgi->add_env_pair (cgi, "SCRIPT_NAME", 11, tmp.buf, tmp.len); 
    554547 
     
    595588        cint_t                             local_len; 
    596589        struct stat                        st; 
    597         cuint_t                            len          = 0; 
    598         cuint_t                            slashes      = 0; 
    599590        cint_t                             pathinfo_len = 0; 
    600591        cherokee_connection_t             *conn         = HANDLER_CONN(cgi); 
     
    624615 
    625616        /* No file checking: mainly for FastCGI and SCGI 
    626          * Examples: 
    627          * 
    628          * Webdir:         /demo/subdirectory 
    629          * Request:        http://localhost/demo/subdirectory/ 
    630          * SCRIPT_NAME':   /demo/subdirectory/ 
    631          * PATH_INFO:      <empty> 
    632          *  
    633          * Webdir:         / 
    634          * Request         http://localhost/another/large/one/foo 
    635          * SCRIPT_NAME:    /another 
    636          * PATH_INFO:      /large/one/foo 
    637          * 
    638          * Webdir:         / 
    639          * Request:        http://localhost/ 
    640          * SCRIPT_NAME:    / 
    641          * PATH_INFO:      <empty> 
    642617         */ 
    643618        if ((! props->check_file) && 
    644             (! cherokee_buffer_is_empty (&conn->web_directory)))  
     619            (! cherokee_buffer_is_empty(&conn->web_directory)))  
    645620        { 
    646                 if (conn->web_directory.len > 1) { 
    647                         len += conn->web_directory.len; 
    648                 } 
    649  
    650                 while (len < conn->request.len) { 
    651                         if (conn->request.buf[len] == '/') { 
    652                                 if (slashes == 1)  
    653                                         break; 
    654                                 slashes = 1; 
    655                         } 
    656                         len ++; 
    657                 } 
    658  
    659                 cherokee_buffer_add (&conn->pathinfo,  
    660                                      conn->request.buf + len, 
    661                                      conn->request.len - len); 
    662  
     621                if (conn->request.len == 1) { 
     622                        cherokee_buffer_add_str (&conn->pathinfo, "/"); 
     623 
     624                } else if (conn->web_directory.len == 1) { 
     625                        cherokee_buffer_add_buffer (&conn->pathinfo, &conn->request); 
     626                                                     
     627                } else { 
     628                        cherokee_buffer_add (&conn->pathinfo, 
     629                                             conn->request.buf + conn->web_directory.len, 
     630                                             conn->request.len - conn->web_directory.len); 
     631                } 
    663632                return ret_ok; 
    664633        }