Changeset 1925
- Timestamp:
- 09/01/08 12:09:18 (3 months ago)
- Files:
-
- cherokee/trunk/cherokee/handler_cgi_base.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cherokee/trunk/cherokee/handler_cgi_base.c
r1924 r1925 533 533 534 534 /* 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 543 536 */ 544 537 cherokee_buffer_clean (&tmp); 545 538 546 539 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 553 546 cgi->add_env_pair (cgi, "SCRIPT_NAME", 11, tmp.buf, tmp.len); 554 547 … … 595 588 cint_t local_len; 596 589 struct stat st; 597 cuint_t len = 0;598 cuint_t slashes = 0;599 590 cint_t pathinfo_len = 0; 600 591 cherokee_connection_t *conn = HANDLER_CONN(cgi); … … 624 615 625 616 /* No file checking: mainly for FastCGI and SCGI 626 * Examples:627 *628 * Webdir: /demo/subdirectory629 * Request: http://localhost/demo/subdirectory/630 * SCRIPT_NAME': /demo/subdirectory/631 * PATH_INFO: <empty>632 *633 * Webdir: /634 * Request http://localhost/another/large/one/foo635 * SCRIPT_NAME: /another636 * PATH_INFO: /large/one/foo637 *638 * Webdir: /639 * Request: http://localhost/640 * SCRIPT_NAME: /641 * PATH_INFO: <empty>642 617 */ 643 618 if ((! props->check_file) && 644 (! cherokee_buffer_is_empty (&conn->web_directory)))619 (! cherokee_buffer_is_empty(&conn->web_directory))) 645 620 { 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 } 663 632 return ret_ok; 664 633 }